The purpose of this first tutorial is to explain the very basics of the Arduino IDE which you can download here. Don’t get fooled by its appearance. This IDE might look simple but it is extremely powerful.
In my opinion, what gives this tool its power it’s not only the appearance or the lack of complex features (which makes it easier to use) but all the examples, projects and libraries which are freely distributed by the open-source community. Even though, the Arduino project thrives. In fact, it thrives because it is open-source, like Linux or the Raspberry Pi.
This is how the IDE looks:
So you can easily understand how the IDE works and to prove we (the open-source community) are right, let’s start with a simple LED blink schematic. For this tutorial you need:
– 1x Arduino Nano 3.0
– 1x LED
– 1x 10kOhm resistors
– Breadboard and wires
Now you have to replicate the circuit below:
The circuit can be powered via Arduino’s USB port or applying 12V in Arduino’s Vin pin.
The blinking code follows below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
/***************************************************************************** * Copyright (C) 2012 by Vasco Ferraz. All Rights Reserved. * * * * This program is free software: you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation, either version 3 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * * * * Author: Vasco Ferraz * * Contact: http://vascoferraz.com/contact/ * * Description: http://vascoferraz.com/tutorials/arduino-ide/ * *****************************************************************************/ // The setup function runs only once when you power or reset the board void setup() { pinMode(2, OUTPUT); // Initialize digital pin 2 as an output } // The loop function runs indefinitely after the setup function ends void loop() { digitalWrite(2, HIGH); // Turn on the LED. This line will put 5 Volt (HIGH) in digital pin 2 delay(100); // Wait for 100 milliseconds (0.1 seconds) with the LED on digitalWrite(2, LOW); // Turn the LED off by making the voltage LOW (Zero Volt) delay(1000); // Wait for 1000 milliseconds (1 second) with the LED off } |
There are three major steps you must understand before uploading the code inside Arduino’s flash memory.
First, you have to select which Arduino board you’re using by clicking Tools > Board. A list of all available boards will appear so you can select the one you’re using. Another menu will appear if the board you selected has more than one processor to choose. Just change it accordingly by clicking in: Tools > Processor.
Second, you must select the serial port. Again, click Tools > Port and select the COM port where you’ve connected the Arduino. If you’re not sure which port is the right one, disconnect your Arduino board and re-open the menu. The entry that disappears should be the Arduino board. Reconnect the board and select that serial port.
Finally, click Tools > Programmer and select Arduino as ISP.
To upload the program, copy and paste this code into the IDE. Then, click the “Upload” button and if everything is OK you should see the RX and TX LEDs on the board flashing. If the upload is successful, the message “Done uploading.” will appear in the status bar and you should see the LED blinking. Yeah! You’re good 🙂