38 lines
918 B
Arduino
38 lines
918 B
Arduino
|
/*
|
||
|
RGB Blink
|
||
|
Alternates R, G and B LED on for one second, then off for one second, repeatedly.
|
||
|
|
||
|
This example code is in the public domain.
|
||
|
|
||
|
modified 20 May 2016
|
||
|
by Shawn Nock
|
||
|
*/
|
||
|
|
||
|
#define RED 2
|
||
|
#define GREEN 3
|
||
|
#define BLUE 4
|
||
|
|
||
|
int delay_ms = 1000; // How long to keep LEDs on and off in milliseconds (sec/1000)
|
||
|
|
||
|
void setup() {
|
||
|
// initialize digital pin 13 as an output.
|
||
|
pinMode(RED, OUTPUT);
|
||
|
pinMode(GREEN, OUTPUT);
|
||
|
pinMode(BLUE, OUTPUT);
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
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);
|
||
|
}
|