Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C++ code
- //
- void setup()
- {
- pinMode(2, OUTPUT); //red
- pinMode(3, OUTPUT); //yellow
- pinMode(4, OUTPUT); //orange
- pinMode(5, OUTPUT); //blue
- pinMode(6, OUTPUT); //green
- pinMode(7, OUTPUT); //white
- }
- void loop()
- {
- //Red LED ON and OFF once
- funRedLedOnOff();
- //Yellow LED ON and OFF once
- funYellowLedOnOff();
- //Orange LED ON and OFF once
- funOrangeLedOnOff();
- //Blue LED ON and OFF once
- funBlueLedOnOff();
- //Green LED ON and OFF once
- funGreenLedOnOff();
- //White LED ON and OFF once
- funWhiteLedOnOff();
- funGreenLedOnOff();
- funYellowLedOnOff();
- funRedLedOnOff();
- funWhiteLedOnOff();
- funBlueLedOnOff();
- funOrangeLedOnOff();
- funRedLedOn();
- delay(1000);
- funGreenLedOn();
- delay(1000);
- funAllLedOff();
- delay(1000);
- }
- void funRedLedOnOff()
- {
- //Red LED ON and OFF once
- digitalWrite(2, HIGH);
- delay(500); //wait 0.5 sec
- digitalWrite(2, LOW);
- delay(500);
- }
- void funYellowLedOnOff()
- {
- digitalWrite(3, HIGH);
- delay(500);
- digitalWrite(3, LOW);
- delay(500);
- }
- void funOrangeLedOnOff()
- {
- digitalWrite(4, HIGH);
- delay(500);
- digitalWrite(4, LOW);
- delay(500);
- }
- void funBlueLedOnOff()
- {
- digitalWrite(5, HIGH);
- delay(500);
- digitalWrite(5, LOW);
- delay(500);
- }
- void funGreenLedOnOff()
- {
- digitalWrite(6, HIGH);
- delay(500);
- digitalWrite(6, LOW);
- delay(500);
- }
- void funWhiteLedOnOff()
- {
- digitalWrite(7, HIGH);
- delay(500);
- digitalWrite(7, LOW);
- delay(500);
- }
- void funRedLedOn()
- {
- digitalWrite(2,HIGH);
- }
- void funRedLedOff()
- {
- digitalWrite(2,LOW);
- }
- void funGreenLedOn()
- {
- digitalWrite(6,HIGH);
- }
- void funGreenLedOff()
- {
- digitalWrite(6,LOW);
- }
- void funAllLedOff()
- {
- digitalWrite(2,LOW);
- digitalWrite(3,LOW);
- digitalWrite(4,LOW);
- digitalWrite(5,LOW);
- digitalWrite(6,LOW);
- digitalWrite(7,LOW);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement