Description
To build the LED blinker I first connected the LED to pin 13 and via the register the the ground and uploaded the program to the arduino.
To make it fun, I added two leds, one red(R) one blue(B) and then put a program to switch them on in a pattern followed by the police car lights. The pattern is BB RR BB RR BR BR BR BR. I brought down the frequency to 100ms.
Components Used
1- Arduino
1- 220-ohm resisitor
2- LED
1- Breadboard
Code
int red = 13;
int blue = 7;
void setup()
{
pinMode(red, OUTPUT);
pinMode(blue, OUTPUT);
}
void loop()
{
//blue blue
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
delay(100);
//red red
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
delay(100);
//blue blue
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
delay(100);
//red red
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, LOW);
delay(100);
//blue red
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
delay(100);
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
delay(100);
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
delay(100);
digitalWrite(blue, HIGH);
digitalWrite(red, LOW);
delay(100);
digitalWrite(blue, LOW);
digitalWrite(red, HIGH);
delay(100);
}
- Login to post comments