Advertisement
JonD1988

RelayModuleTest

Dec 28th, 2022
1,448
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define R1p 4 //Relay 1 is ESP32 GPIO 4
  2. #define R2p 16 //Relay 2 is ESP32 GPIO 16
  3. #define R3p 17 //Relay 3 is ESP32 GPIO 17
  4. #define R4p 18 //Relay 4 is ESP32 GPIO 18
  5. #define R5p 19 //Relay 5 is ESP32 GPIO 19
  6. #define R6p 21 //Relay 6 is ESP32 GPIO 21
  7. #define R7p 22 //Relay 7 is ESP32 GPIO 22
  8. #define R8p 23 //Relay 8 is ESP32 GPIO 23
  9. void setup() {
  10.   pinMode(R1p, OUTPUT); //Sets specified pin as an output
  11.   pinMode(R2p, OUTPUT); //Sets specified pin as an output
  12.   pinMode(R3p, OUTPUT); //Sets specified pin as an output
  13.   pinMode(R4p, OUTPUT); //Sets specified pin as an output
  14.   pinMode(R5p, OUTPUT); //Sets specified pin as an output
  15.   pinMode(R6p, OUTPUT); //Sets specified pin as an output
  16.   pinMode(R7p, OUTPUT); //Sets specified pin as an output
  17.   pinMode(R8p, OUTPUT); //Sets specified pin as an output
  18.   digitalWrite(R1p, HIGH); //Turns relay module off initially since it is active high
  19.   digitalWrite(R2p, HIGH); //Turns relay module off initially since it is active high
  20.   digitalWrite(R3p, HIGH); //Turns relay module off initially since it is active high
  21.   digitalWrite(R4p, HIGH); //Turns relay module off initially since it is active high
  22.   digitalWrite(R5p, HIGH); //Turns relay module off initially since it is active high
  23.   digitalWrite(R6p, HIGH); //Turns relay module off initially since it is active high
  24.   digitalWrite(R7p, HIGH); //Turns relay module off initially since it is active high
  25.   digitalWrite(R8p, HIGH); //Turns relay module off initially since it is active high
  26. }
  27.  
  28. void loop() {
  29.   digitalWrite(R1p, LOW); //Turns relay module off initially since it is active high
  30.   digitalWrite(R2p, LOW); //Turns relay module off initially since it is active high
  31.   digitalWrite(R3p, LOW); //Turns relay module off initially since it is active high
  32.   digitalWrite(R4p, LOW); //Turns relay module off initially since it is active high
  33.   digitalWrite(R5p, LOW); //Turns relay module off initially since it is active high
  34.   digitalWrite(R6p, LOW); //Turns relay module off initially since it is active high
  35.   digitalWrite(R7p, LOW); //Turns relay module off initially since it is active high
  36.   digitalWrite(R8p, LOW); //Turns relay module off initially since it is active high
  37.   delay(5000);
  38.   digitalWrite(R1p, HIGH); //Turns relay module off initially since it is active high
  39.   digitalWrite(R2p, HIGH); //Turns relay module off initially since it is active high
  40.   digitalWrite(R3p, HIGH); //Turns relay module off initially since it is active high
  41.   digitalWrite(R4p, HIGH); //Turns relay module off initially since it is active high
  42.   digitalWrite(R5p, HIGH); //Turns relay module off initially since it is active high
  43.   digitalWrite(R6p, HIGH); //Turns relay module off initially since it is active high
  44.   digitalWrite(R7p, HIGH); //Turns relay module off initially since it is active high
  45.   digitalWrite(R8p, HIGH); //Turns relay module off initially since it is active high
  46.   delay(5000);
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement