Connecting a relay to Arduino

 

 

/*
  KMTronic Relay control
  Turns on an Relays on and off for half second, repeatedly.
 
  This example code is in the public domain.
 */

void setup() {                
  // initialize the digital pin's as an output.
  pinMode(12, OUTPUT);    // Relay 1 
  pinMode(13, OUTPUT);    // Relay 2
}

void loop() {
  digitalWrite(12, HIGH);   // set the Relay 1 on
  delay(500);              // wait for a half second
  digitalWrite(12, LOW);    // set the Relay 1 off
  delay(500);              // wait for a half second
  digitalWrite(13, HIGH);   // set the Relay 2 on
  delay(500);              // wait for a half second
  digitalWrite(13, LOW);    // set the Relay 2 off
  delay(500);              // wait for a half second   
}








back to Arduino DINo projects

 

Read 14994 times