Description
For this lab we built our first circuit using the Arduino Uno. I connected the Arduino Uno to a Macbook Pro and changed the example code of "Blink" to turn on the led for 4 seconds and off for 2 seconds.
Components
1 Arduino Uno
1 Breadboard
1 red led
1 220 Ohm resistor
cables
Code
/*
The Blinking Led
Turns on an LED on for 4 seconds, then off for 2 seconds, repeatedly.
*/
// Pin 13 has an LED connected on the Arduino board. Let's name it ledPin.
int ledPin = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(ledPin, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(ledPin, HIGH); // turn the LED on (HIGH is the voltage level)
delay(4000); // wait for 4 seconds
digitalWrite(ledPin, LOW); // turn the LED off by making the voltage LOW
delay(2000); // wait for 2 seconds
}
- Login to post comments