In this one, I am now trying to make lots of lights blink.
In the first example, I just put 6 lights in parallel all on the same pin 13 that was used before. The code did not change at all. Just the image changed.
In the next, I then tried playing with the code to get a sort of Night Rider effect with the lights going down a line and back. I also wanted to speed up the delay between one LED off and the next On. This helped to smooth out the effect.
--------------------------------------------------------------------
//6 LED Blink Sequence - Written by Philip Leete
#define LED1 1 //I used this naming policy just so I could keep track of where the lights were.
#define LED2 2 //Each led is assigned to the corrisponding pin
#define LED3 3
#define LED4 4
#define LED5 5
#define LED6 6
void setup()
{
pinMode(LED1, OUTPUT); //This is naming each of the led as an output
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
}
void loop() //This void loop will turn on all LED's and then turn on one at a time as it ripples down the line and back.
{
digitalWrite(LED1, LOW); //Notice that the first time throught the loop will turn on all LEDs
delay(100); //After that, it will sequence each off and back on
digitalWrite(LED1, HIGH); //And if I did my math correctly, each step should take 1/10th of a second. There are 10 steps. Total time - 1 second
digitalWrite(LED2, LOW);
delay(100);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, LOW);
delay(100);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, LOW);
delay(100);
digitalWrite(LED4, HIGH);
digitalWrite(LED5, LOW);
delay(100);
digitalWrite(LED5, HIGH);
digitalWrite(LED6, LOW);
delay(100);
digitalWrite(LED6, HIGH);
digitalWrite(LED5, LOW);
delay(100);
digitalWrite(LED5, HIGH);
digitalWrite(LED4, LOW);
delay(100);
digitalWrite(LED4, HIGH);
digitalWrite(LED3, LOW);
delay(100);
digitalWrite(LED3, HIGH);
digitalWrite(LED2, LOW);
delay(100);
digitalWrite(LED2, HIGH);
}
The effect was cool but still not real brilliant. So I will do more later. On to other things on this Morning.
No comments:
Post a Comment