Lab1 - Blink LED
To make LED blink I constructed a circuit of (pin 13 - 220ohm resistor - LED - ground). And then, I implemented a short code to make it blink for random seconds.
Components Used
1- 220ohm Resister
1- breadboard
1- LED
Code
int ledPin = 13;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
for (int i = 0; i < 10; i++) {
int sec = random(10); // to set blinking time randomly.
sec = sec * 1000;
digitalWrite(ledPin, HIGH);
delay(sec); // LED is on for random seconds.
digitalWrite(ledPin, LOW);
delay(1000);
}
}
Image
attached.
- Login to post comments
Drupal theme by Kiwi Themes.