How to connect Arduino uno to relay module very simple

This article shows how to control mains voltage with the Arduino using a relay module. We make a brief introduction to the relay module and build a simple project example with the Arduino. The example we’ll build shows how to control a relay module with an Arduino and a simple project.


Hardware Required

Arduino or Genuino 
BoardRelay module
Male & Female jumpers

  • You can connect the wire of light -


Arduino uno - Relay module
8                     - IN1(Relay 1)
9                     - IN2(Relay 2)
GND              - GND(Control)
5V                  - VCC(Power)

Code

int ledone = 8;
int ledtwo = 9;
void setup() {  
  pinMode(ledone, OUTPUT);
  pinMode(ledtwo, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
   digitalWrite(ledone,HIGH);                         
   digitalWrite(ledtwo,HIGH);
   delay(1000);                       // wait for a second
   digitalWrite(ledone,LOW);                         
   digitalWrite(ledtwo,LOW);
   delay(1000);                       // wait for a second
}

No comments

Powered by Blogger.