Description
Our first lab assignment was an introduction to Arduino and physical computing. We installed the Arduino software onto our computers and created a simple circuit to make an LED flash on and off. I modified the existing code which turns an LED on for one second and off for one second to flash on for only a tenth of a second and off for 5 seconds.
Components Used
1- Arduino UNO
1- breadboard
1- LED
1- 220 ohm resistor
2- colored wires
Code
/*This code is modified from the Blink example code to make an LED turn on for a tenth of a second and then off for five seconds, repeatedly. */
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(100); // wait for a tenth of a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(5000); // wait for five seconds
}
- Login to post comments