Open Arduino IDE and write code

How it's done

To control each relay channel we have to send LOW signal from Arduino pin.

int a = 13;
int b = 12;
int c = 11;
int d = 10;

void setup(){

pinMode(a, OUTPUT);
pinMode(b, OUTPUT);
pinMode(c, OUTPUT);
pinMode(d, OUTPUT);


void loop(){
digitalWrite(a, LOW);
digitalWrite(b, LOW);
digitalWrite(c, LOW);
digitalWrite(d, LOW);

Extra info:

We initialize four variables for relay channels (a, b, c and d). To each variable, we set one pin from Arduino.

In setup function we have to set pinMode as output for all channel pins.

Finally we control relay switch by sending LOW/HIGH signal using digitalWrite function. LOW signal will turn relay ON and HIGH signal will turn relay OFF. Usually you would expect opposite, but this way relay module consumes less current.

Activity Q&A

Need help with this activity?Add the first post