My first Arduino project
So now I have a smattering of components that have cost me less than a tenner, the question is what I can do with them in the form of a project. Immediately I go searching the internet for massive and complex projects, such as weather systems and security keypads, but it is only right that I start somewhere simple. You can get much simpler than a blinking light, so this is the way I go.
Of course, it would help to know much more about how electronics work. While I feel I already have a rudimentary understanding of electronics, it never hurts to have a recap. I’ll be paraphrasing some of my findings as i go along, but Intructables have a great blog post here to get anyone started.
The Arduino site has a wealth of tutorials, so I’ll be following the first of these tutorials, which is the ‘blink’ lesson. The only difference is that I am using a breadboard and extra leads to make the process a little more clear and easier.
Hardware Required
- Arduino
- LED
- 220 ohm to 1k resistor
- breadboard
- leads
To make a blinking LED, you don’t even need anything other than the Arduino itself, as the Arduino has a number of LED status light that can be controlled. However, as I wanted to create my own closed circuit, I opted to get this code working with an external LED.
To make a closed circuit, I attach a lead to the ground port of the Arduino to position a1 of my breadboard. The LED is straddled across position b1 and b2, with the resister straddled across position c2 and c15. Another lead is put in position c15 and put into pin 13 of the Arduino board. The setup looks like this:
What this means now is that we have a closed circuit from the Arduino, linking the resistor and the led in the process, to pin 13. We can then use a small program to program pin 13 and therefore control the circuit.
The program
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
Most Arduinos have an on-board LED you can control. On the Uno and
Leonardo, it is attached to digital pin 13. If you’re unsure what
pin the on-board LED is connected to on your Arduino model, check
the documentation at http://www.arduino.cc
This example code is in the public domain.
modified 8 May 2014
by Scott Fitzgerald
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}