Introduction: Getting Started With Arduino
Hi there Guys, Gals and fellow Robots
This here is my first Instructable project. What better way to start this journey than with a hello world tutorial on the oh so familiar Arduino.
Arduino is an open-source piece of hardware with complimentary open-source software that allows engineering students, hackers, tinkerers and hobbyists to create and learn a lot about software and electronics.
To get your hands on one of these Awesome little planet conquering devices just visit one of the following websites:
if you don't have one already.
The above diagram, lists the pins on the Arduino and there respective functions. Don't feel intimidated if this is the first time you see this diagram, you will become familiar with it and it will become an essential tool for your future projects.
Now lets get into it....
Step 1: Getting the Software
Before we can make any lights blink or take over the world with Arduino minions we must install the Arduino IDE (Integrated Development Environment) so that we can write the program.
To download the software head over to the Arduino site: https://www.arduino.cc and click on the Download tab. Download and installation is pretty straight forward and self explanatory...
Step 2: Software Is Your Friend
Once you have installed the software and launched the application you should see this nice litre green window, with the text:
these are known as functions and your code will be placed within the curly braces.
The "void" statement tells us that no values are returned by the functions (don't worry more on this in a later instruct able). The setup() function is only executed once when the Arduino is powered on then once all the code is executed, the Arduino moves to the loop() function.
The loop() function executes whatever code is inside the curly braces forever (well until it runs out of power is probably more likely).
Step 3: Remember to Blink
Now lets blink that LED...
Simply download the sketch below, or copy the code in the image above, ensure the correct port is selected for your board and then click the "upload" arrow. Now sit back and watch your invention blink like a Boss!!
Now its time to do some explaining...
The Arduino Uno board has a built in LED that is tied to digital pin 13, which is marked on this particular board by the letter "L" and is located close to the actual pin 13.
The first line of the "sketch" (Arduino for code) is the line "//Global variable led", this is a single line comment and is commonly used in many coding languages such as C, C++ and Java for example. The two forward slashes is what tells the IDE that the text to the right is a comment and can be ignored by the Arduino. Comments are only there for hints and guides for the programmer, tinkerer and hobbyist, but are essential when programs become very large and hard to follow.
The second line "const int led = 13;"
declares a constant integer variable with the name "led" and the value 13. This is done so that if we decide to change the pin we want to "blink" we only need to change the value in one place. Note that to declare a global variable it must be done outside any function and preferably close to the top of the "sketch".
The pinMode() function
This function is built into the Arduino IDE and is used to let the Arduino know that we intend to use pin 13 as an OUTPUT. This allows us to change the state of the led to HIGH (5V) and to LOW (0V) which is done with the use of the digitalWrite() (also a built in function) function in the loop() function.
The delay() function
This is also a very useful built in function and it completely "pauses" the program for the time passed to it within it in milliseconds. Thus the line "delay(1000);" will delay the program by 1000 milli seconds or also known as 1 second.