This project series is a means by which I am testing out the various ways of blogging similar projects easily. So they are not designed to be instructional as such, more a testbed. Having said that, if they are useful, feel free to use them and have fun!
What the Project Does:
- We are going to make 5 LEDs turn on and off, one after the other.
What are we Learning?
- How to write a simple Arduino sketch, with comments
- How to allocate input/output pins and set them high or low.
- How to connect LEDs correctly to the Arduino board.
Here’s my sketch, which I have also used to record the algorithm.
Title: LED Wave
Author: Mike Isted
Date: 16 June 2014
Description: We are going to connect 5 LEDs to the Arduino and make them flah in turn, making a kind of wave.
1. Turn on LED 1
2. Wait 0.5 s
3. Turn off LED 1
4. Turn on LED 2
5. Wait 0.5 s
6. Turn off LED 2
7. Do same for LED’s 3,4 and 5. Then repeat from LED1.
8. Repeat forever.
pinMode(2, OUTPUT); //Define required pins as outputs.
digitalWrite(2, HIGH); // Turn on LED1 connected to pin 2
delay(500); // Wait 500milliseconds (1/2s)
digitalWrite(2, LOW); // Turn off LED
// The process will now repeat because this is an endless loop.
I’m using the Sparkfun Inventor’s Kit to build many of these projects. The kit uses a breadboard to allow circuits to be built just by pushing components and wires together. It also contains alot of fun sensors to experiment with!
So here is the circuit made up:
What did I Learn?
- Make sure you know which COM port the Arduino is attached to;
- Make sure the connections are correct across the breadboard – I missed a couple becuase they are small;
- Make the the resistors are the correct size (330 Ohms). I accidentally used two 10K resistors at first, which meant that two LEDs didn’t light because the current was too small through them.