1
0
Fork 0
unlondon-workshops/sketchbook/Variable-Blink-RGB/Variable-Blink-RGB.ino

42 lines
1.1 KiB
Arduino
Raw Normal View History

2016-05-20 15:00:36 -04:00
/*
RGB Blink
Alternates R, G and B LED on for one second, then off for one second, repeatedly.
The frequency depends on the position of the potentiometer.
This example code is in the public domain.
modified 20 May 2016
by Shawn Nock
*/
#define RED 6
#define GREEN 5
#define BLUE 3
2016-05-20 15:00:36 -04:00
int delay_ms = 1000; // How long to keep LEDs on and off in milliseconds (sec/1000)
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
delay_ms = analogRead(A0);
digitalWrite(RED, HIGH); // turn the LED on (HIGH is the voltage level)
delay(delay_ms); // wait for a second
digitalWrite(RED, LOW); // turn the LED off by making the voltage LOW
delay(delay_ms); // wait for a second
digitalWrite(GREEN, HIGH);
delay(delay_ms);
digitalWrite(GREEN, LOW);
delay(delay_ms);
digitalWrite(BLUE, HIGH);
delay(delay_ms);
digitalWrite(BLUE, LOW);
delay(delay_ms);
}