This will most likely be your first time working with an Arduino board, and this is therefore a very basic guide to get started using this amazing piece of technology.
First a little bit of history: Arduino boards are open-source single-board microcontrollers, made for building digital devices, for a plethora of applications. There are many different Arduino boards, made for specific applications. In this guide, we will be using the Arduino Uno Board, as it is the most popular and widely available board great for almost everything you can think of.
This guide will show you how to set up an Arduino Uno board and how to make it light up a small LED light with only 3 lines of code.
Before you can start using your Arduino Board there are a few (and I mean a few) prerequisites
- An Arduino Uno Board and the USB printer cable (duh)
- One 10k Ohm Resistor (The baby blue one)
- Two Jumper Wires
- One 5mm Standard LED
- One Breadboard
- A Computer with an internet connection
- The Arduino IDE (Where you code)
Step 1 (Setup):
The first thing that we need to do is to clear our table or another working area. When you are ready place the board on your table and get all of the extra accessories ready.
Then go to the Arduino website and download the Integrated Development Environment (IDE), this will be the program you will need to write the code for the board.
Step 2 (Wiring):
When everything is ready we can start putting everything together and write the program that will be used to turn on the LED.
First Configure the LED, resistor, and jumper wires as is shown in the picture below:
Step 3 (PC Connection):
When the board has been configured you can plug the USB cable into the board and into your computer, to power the board and to transfer the program you will be writing.
Step 4 (Coding Setup):
Now that your computer and board are connected you can start programming. Open the Arduino IDE, and follow any directions on the screen. When you get to the Arduino IDE start page press FILE, then press NEW. Congratulations you are ready to code :).
Arduino uses its own programming language, but it is fairly similar to a programming language called C++, so if-statements, loops, etc. use the same syntax.
When you are ready your screen should look something like this:
Step 5 (Programming time):
The first program you will be creating is really simple and you will only need to write 3 lines of code (WOW).
The first line of code will be placed before any of them, and its purpose is to tell the board where the wire that is hooked up with the LED is located. For this program, I will be using Digital Port 12, but you can use whichever one you want.
int LED = 12;
The second line of code will be placed inside the void setup() function, which means the code will run when the board is turned on. The code will be used to indicate what signal the wire should be sending, which in this case is an OUTPUT signal.
The final line of code will be placed inside the void loop() function, which means the code will run in a loop forever and is the main body of the program. The code will be used to turn on the LED, by setting the LED setting to HIGH, which is ON, and LOW is OFF.
This is how the program should look. If you want the program I have created a GitHub Repository, where you can download it (or copy-paste it).
Step 6 (The Finale):
Now that you have the program ready press CTRL + S, to save the program, name it, and find a place to store it on your computer.
When the program is saved it is time to send it to the board. This is done simply by pressing the “Upload” button, which is the one with a little arrow that points to the right.
After approximately 2 seconds you will see your little LED light up, and you are DONE.
Congratulations you have successfully gone through an entire article about a single LED lighting up and done it yourself, and that deserves some recognition.
If you want to learn more about Arduinos you can continue to read my other articles, or you can go to the Arduino Website where you can discover the possibilities of this little piece of technology :).
If you have any questions feel free to put them in the comments below this article :).
Thank you so much for visiting JavaLite, it is incredibly humbling, if you have any feedback feel free to comment below too.