Introduction
In this lesson we will learn how to set up the computer to get started with Arduino, that is, downloading and installing the software and then open and run a simple blinky example.
Installing Arduino Software
Arduino IDE software that we will use to write code and upload it to the board is available in Windows, Mac and Linux. The installation process is different for the three platforms.
Windows
To get started visit the Arduino.cc website and choose between the installer(.exe) or download the zip packages. We prefer the installer since it will install everything you need to use the Arduino software including the drivers.
First, allow the installation process when the download is complete
Secondly, choose for components you want to install.
Thirdly, choose the installation directory. Note, it is better to keep the default one.
When you click on install, the process will extract and install all the required for the Arduino software.
Arduino IDE Software
After we have installed, we launch the software by double-clicking on the Arduino icon created by the installation process.
Now lets get to know the software interface
1/Verify; compiles and approves code. It will catch errors in syntax e.g missing semi-colons, parenthesis etc
2/Upload; Sends code to the Arduino board
3/New; Opens up a new code window tab
4/Open; This button lets you open up an existing sketch
5/Save; This saves the currently active sketch
6/Serial Monitor; Opens a window that displays serial information transmitted by your arduino board
7/Sketch name; Name of the sketch you are currently working on.
8/Code Area; You compose your code here
9/Status Bar; The IDE tells you if there are any errors in your code
Boards and Ports
Before we get programming we also need to tell the Arduino software which type of arduino board we are using and also select the port it is connecting to.
To do this, go to the ‘Tools’ menu and select ‘Board’ e.g Uno
On ‘Tools’ menu you will also find the port option where you will select port the board is connected.
Blinky
Now we are ready to program and our first task is to make the Arduino built-in Led blink.
Arduino has an inbuilt led that is labelled `L’ on the board and the Arduino IDE has a collection of example sketches ready for load up and use including the blink example. To load the blink sketch, Select the File menu, then go to example, 01. Basics then to blink
Upload the code to your Arduino by clicking on the ‘upload’ button. At the status bar you will see updates of compiling sketch which will change to done uploading when complete.
How the ‘blink’ code works
The ‘setup’ function just as in the comment runs when the board resets that is when first powered or after a sketch has been uploaded.It also runs when the reset button on the arduino board is pressed.
The ‘setup’ function has one instruction that sets led pin 13 as an output.
1 2 3 4 5 |
// 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 continuously that is when it finishes running the commands, it starts again over and over unless it is reset.
In the ‘Loop’ function the Led is turned on and then pauses for 1 second(1000ms), then is turned off and pauses again for a second.
1 2 3 4 5 6 7 |
// 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 } |
Exercise
Try changing the delay parameter using 50, 100, 500, 5000 etc.
What do you observe? is the blinking faster or slower?
Next Lessons
For the lessons that will follow we will use the parts below;
- Arduino Uno
- USB cable
- Breadboard
- Jumper wires
- Red, green and Blue Led
- Resistors 330R, 1K, 10K
- 74HC595 shift register
- Diffused RGB Led
- 10k variable resistor
- Push button switch
- Photocell
- Piezo buzzer
- 16*2 LCD display
- TMP36 temperature sensor
- Small DC motor
- Servo motor
Feedback is closed.