Jumping into Arduino microcontrollers can be a bit overwhelming at first. Many first-time coders may want to start with an intricate, complex algorithm, but it’s usually best to start out small - like placing a toe in the pool before diving in.
The schematic above shows a basic parallel circuit using three LEDs. Each LED is connected using a breadboard and resistors. The resistors restrict the flow of electricity to the LEDs - otherwise the voltage would cause the LED to blow. Yikes!
Each blue line on the schematic is a wire that connects to holes in the breadboard or pins on the Arduino UNO. Using the schematic, you can create a similar system using these hardware components.
When the hardware is ready to roll, the program below brings the LEDs to life. This “blink” program can be used to test out your hardware and process for downloading a .ino file to an Arduino UNO microcontroller.
Blinking LEDs Code
/*
Blinking LEDs - test program to run 3 LEDs in a pattern of blinks
*/
int yellowled = 12;
int greenled = 10;
int blueled = 7;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(yellowled, OUTPUT);
pinMode(greenled, OUTPUT);
pinMode(blueled, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// turn the LED on (HIGH is the voltage level)
digitalWrite(yellowled, HIGH);
// wait for 1/2 a second
delay(80);
// turn the LED off by making the voltage LOW
digitalWrite(yellowled, LOW);
// turn the LED on (HIGH is the voltage level)
digitalWrite(greenled, HIGH);
// wait for 1/2 a second
delay(80);
// turn the LED off by making the voltage LOW
digitalWrite(greenled, LOW);
// turn the LED on (HIGH is the voltage level)
digitalWrite(blueled, HIGH);
// wait for 1/2 a second
delay(80);
// turn the LED off by making the voltage LOW
digitalWrite(blueled, LOW);
// wait for a second
delay(500);
}
Comments