L1 - Intro to Physical Computing
Description
Use the Arduino to control a light emitting diode and make it blink in different rate.
Components Used
- Light Emitting Diode (LED)
- Resistor
Arduino Code
/*
Blink
Blinks the LED in a pattern of three times on then one off for half a second each, repeatedly.
void setup() {
// initialize the digital pin as an output.
// Pin 13 has an LED connected on most Arduino boards:
pinMode(13, OUTPUT);
}
void blink_high(int ms) {
digitalWrite(13, HIGH); // set the LED on
delay(ms); // wait for specified number of milliseconds
}
void blink_low(int ms) {
digitalWrite(13, LOW); // set the LED off
delay(ms); // wait for specified number milliseconds
}
void blink(int on, int off) {
blink_high(on);
blink_low(off);
}
void loop() {
blink(500, 250);
blink(500, 250);
blink(500, 1000);
}