loading

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:

void setup(){

}

and

void loop(){

}

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 code...

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.

<p>I always wondered, is there a limited number of writes you get to an Ardunio? You know like how flash drives are? If yes, is it similar to a flash drive how many writes you get? I know zero about Ardunio really. I've been thinking about picking one up lately though, to see if I can manage to get it to do something useful for me.</p>
<p>Hi pfred2 </p><p>Yes there is a limit as to how many times you can write to the Arduino. In the case of the Atmega328, which is the one used in this tutorial it is 10000 times for FLASH storage and 100000 times for EEPROM. When compiling your program it is stored in FLASH memory, so basically you can program it 10000 times. Here is a link to the Atmega328 datasheet that lists everything there is to know about this specific microcontroller </p><p><a href="http://www.atmel.com/images/atmel-8271-8-bit-avr-microcontroller-atmega48a-48pa-88a-88pa-168a-168pa-328-328p_datasheet_complete.pdf" rel="nofollow">http://www.atmel.com/images/atmel-8271-8-bit-avr-m...</a></p>
<p>Thanks. I assumed as much. 10,000 writes is about what regular flash memory can withstand too I believe.Well if I wrote a program a day every day it would hold up for over 27 years, so not too bad I guess. Everything there is to know might be a bit more than I want to know. I just got my first ATmega in the form of a transistor tester the other day. I really like it.</p>
<p>Yes I really like the Arduino platform, it is really easy to learn and you can build some really awesome stuff. I just finished building an Arduino GPS data logger. It saves latitude and longitudinal coordinates to a SD card and can communicate with my PC over bluetooth. I will make an Instructable on it at a later time.</p>
<p>Nice tutorial. Thanks for sharing.</p>
Thank you, It is my first Tutorial. I hope to add some more content on a regular basis.

About This Instructable

2,262views

79favorites

License:

Bio: I am currently doing an extended major in Mechatronic engineering. I am interested in using the electronics, software and mechanics to make the world a ... More »
More by cobus002:Arduino Buttons Made Simple Getting Started With Arduino 
Add instructable to: