Arduino Interface Relay.JPG

Code

  1. /*
  2. Can we turn on the bulb? with Relay
  3. Turns on an Relay on for one second, then off for one second, repeatedly.
  4. */
  5.  
  6. // Pin 13 has an LED connected on most Arduino boards.
  7. // give it a name:
  8. int Relay = 13;
  9. // the setup routine runs once when you press reset:
  10. void setup() {
  11. // initialize the digital pin as an output.
  12. pinMode(Relay, OUTPUT);
  13. }
  14. // the loop routine runs over and over again forever:
  15. void loop() {
  16. digitalWrite(Relay, HIGH); // turn the LED on (HIGH is the voltage level)
  17. delay(1000); // wait for a second
  18. digitalWrite(Relay, LOW); // turn the LED off by making the voltage LOW
  19. delay(1000); // wait for a second
  20. }