// https://programmersqtcpp.blogspot.com/2022/06/la-classe-relay-highlow-level-trigger.html
#include <LiquidCrystal.h>
#include "relay.h"

const char *onoff_str(const bool i) { 
    static char *onoff[] = { "OFF", "ON " };
    return onoff[i];
} 
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

// Relay(pin, levelTrigger)
Relay relayOnD6(6, HIGH);   // High Level Trigger
Relay relayOnD5(5, LOW);    // Low Level Trigger

void setup()
{
    Serial.begin(115200);
    
    lcd.begin(16, 2);
    relayOnD6.begin();
    relayOnD5.begin();

    // operate on relay connected on D6   
    Serial.println("## Relay state on D6 ##");
    Serial.println(onoff_str(relayOnD6.state()));
    delay(500);
    
    relayOnD6.set(ON);
    Serial.println(onoff_str(relayOnD6.state()));
    delay(500);
    
    relayOnD6.set(OFF);
    Serial.println(onoff_str(relayOnD6.state()));
    delay(500);
    
    relayOnD6.set(ON);
    Serial.println(onoff_str(relayOnD6.state()));
    delay(500);
    
    relayOnD6.set(OFF);
    Serial.println(onoff_str(relayOnD6.state()));
    delay(500);

     // operate on relay connected on D5   
    Serial.println("## Relay state on D5 ##"); 
    Serial.println(onoff_str(relayOnD5.state()));
    delay(500);

    relayOnD5.set(ON);
    Serial.println(onoff_str(relayOnD5.state()));
    delay(500);
    
    relayOnD5.set(OFF);
    Serial.println(onoff_str(relayOnD5.state()));
    delay(500);
    
    relayOnD5.set(ON);
    Serial.println(onoff_str(relayOnD5.state()));
    delay(500);
    
    relayOnD5.set(OFF);
    Serial.println(onoff_str(relayOnD5.state()));

} // end void setup()

void loop() {
    // empty loop
   
} // end void loop()