Star Code
/*
Star with Pin 3 = green LEDs, Pin 5 = Red LEDs and Pin 6 = Blue LEDs
jrich 12/2014
*/
// define variables
int green = 3;
int red = 5;
int blue = 6;
int x = 1; // a counter
int delay1=250; // adjustable delay
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pins as an output.
pinMode(green, OUTPUT);
pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
//flash green
while (x<4)
{
digitalWrite(green, HIGH); // turn the LED on (HIGH is the voltage level)
delay (500);
digitalWrite(green, LOW); // turn the LED on (HIGH is the voltage level)
delay (500);
x=x+1; // increment x
}
x=1; // reset x for later use
//flash red
while (x<4)
{
digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level)
delay (500);
digitalWrite(red, LOW); // turn the LED on (HIGH is the voltage level)
delay (500);
x=x+1; // increment x
}
x=1; // reset x for later use
//flash blue
while (x<4)
{
digitalWrite(blue, HIGH); // turn the LED on (HIGH is the voltage level)
delay (500);
digitalWrite(blue, LOW); // turn the LED on (HIGH is the voltage level)
delay (500);
x=x+1; // increment x
}
x=1; // reset x for later use
//cycle colors
while (x<25)
{
digitalWrite(green, HIGH); // turn the LED on (HIGH is the voltage level)
delay (delay1-x*10);
digitalWrite(green, LOW); // turn the LED on (HIGH is the voltage level)
delay (delay1-x*10);
digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level)
delay (delay1-x*10);
digitalWrite(red, LOW); // turn the LED on (HIGH is the voltage level)
delay (delay1-x*10);
digitalWrite(blue, HIGH); // turn the LED on (HIGH is the voltage level)
delay (delay1-x*10);
digitalWrite(blue, LOW); // turn the LED on (HIGH is the voltage level)
delay (delay1-x*10);
x=x+1; // increment x
}
x=1; // reset x for later use
digitalWrite(green, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(red, HIGH); // turn the LED on (HIGH is the voltage level)
digitalWrite(blue, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000);
// wait for a second
digitalWrite(green, LOW); // turn the LED off by making the voltage LOW
digitalWrite(red, LOW); // turn the LED off by making the voltage LOW
digitalWrite(blue, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a 1/2 second
}