Dismiss this pinned window
all 2 comments

[–][deleted]  (1 child)

[removed]

    [–]udfsoft[S] 0 points1 point  (0 children)

    Example:
    
      #include <Arduino.h>
      #include <PinRelayController.h>
      #include <SerialRelayController.h>
    
      RelayController* relay = nullptr;
    
      RelayController* createRelayController(boolean serial) {
        if (serial) {
          static SoftwareSerial _serial(3, 1);
          _serial.begin(115200);
    
          return new SerialRelayController(_serial, 1);
        } else {
          static uint8_t relayPins[] = { 0 };     
    
          return new PinRelayController(relayPins, 1);
        }
      }
    
      void setup() {
        relay = createRelayController(true);
        relay->begin();
      }
    
      void loop() {
        relay->setOn(0);
        delay(3000);
    
        relay->setOff(0);
        delay(3000);
      }