Randomly Blinking LEDs on Arduino UNO
Hi guys,
So today I got my hands on an Arduino UNO R3, and this was the first time I was working on some hardware stuff, as I am not interested in both hardware and electronics. But I was interested in “Hardware Hacking” so bought one.
First thing I did after getting the Arduino, I googled “Arduino for beginners” but that was confusing. So I watched a youtube video on “Blinking a LED on Arduino”. That was enough to understand basics about Arduino. I did the same and Hooray! I build my first project on Arduino. But I was not happy, so I thought to make something different out of it. So I added some more LEDs and thought to blink them randomly and fast.
Now this was looking awesome, then I thought to make these LEDs respond on music beats, which I am working on for that I need some sensors, so those are on the way. For now let me share that simple C code with you.
int red1 = 13;
int red2 = 12;int yellow1 = 11;
int yellow2 = 10;int green1 = 9;
int green2 = 8;long randOn = 0;
long randOff = 0;void setup() {randomSeed(analogRead(0));
pinMode(red1, OUTPUT);
pinMode(red2, OUTPUT);
pinMode(yellow1, OUTPUT);
pinMode(yellow2, OUTPUT);pinMode(green1, OUTPUT);
pinMode(green2, OUTPUT);
}void loop() {
randOn = random(100,1200);
randOff = random(200,900);const byte leds[] = {13,12,11,10,9,8};
byte led;led = leds[random(0,6)];
digitalWrite(led, HIGH);
delay(50);
digitalWrite(led, LOW);
delay(50);}
Here I attached these 6 LEDs in input 8–13 on Arduino board.
Thanks!
