Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Pin 13 has an LED connected on most Arduino boards.
- // give it a name:
- int ledRed = 13;
- int ledGreen = 12;
- int ledBlue = 11;
- int switchPin = 0;
- int switchState = LOW;
- // the setup routine runs once when you press reset:
- void setup() {
- // initialize the digital pin as an output.
- pinMode(ledRed, OUTPUT);
- pinMode(switchPin, INPUT);
- }
- // the loop routine runs over and over again forever:
- void loop() {
- switchState = digitalRead(switchPin);
- if (switchState == LOW) { delayTime = 500; } else { delayTime = 250; }
- digitalWrite(ledRed, HIGH); // turn the LED on (HIGH is the voltage level)
- delay(delayTime); // wait for a second
- digitalWrite(ledRed, LOW); // turn the LED off by making the voltage LOW
- digitalWrite(ledGreen, HIGH); // turn the LED on (HIGH is the voltage level)
- delay(delayTime); // wait for a second
- digitalWrite(ledGreen, LOW); // turn the LED off by making the voltage LOW
- digitalWrite(ledBlue, HIGH); // turn the LED on (HIGH is the voltage level)
- delay(delayTime); // wait for a second
- digitalWrite(ledBlue, LOW); // turn the LED off by making the voltage LOW
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement