element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Arduino Tutorials
  • Products
  • Arduino
  • Arduino Tutorials
  • More
  • Cancel
Arduino Tutorials
Blog Getting to Know Arduino : Part 1 : Hello, World!
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Arduino Tutorials to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: cstanton
  • Date Created: 28 Mar 2014 9:24 AM Date Created
  • Views 9629 views
  • Likes 15 likes
  • Comments 33 comments
  • tutorial
  • min
  • 10
  • arduino uno
  • arduino-uno
  • ardunio
  • microcontrollers
  • 10minarduino
  • programming
  • getting-to-know
  • atmega328
  • tutorials
  • atmega328p
  • microcontroller
  • minute
  • 10minutearduino
  • uno
  • getting_to_know
  • getting to know
  • c++
  • arduino
  • feature tutorial
  • feature_tutorial
  • atmel
Related
Recommended

Getting to Know Arduino : Part 1 : Hello, World!

cstanton
cstanton
28 Mar 2014

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

Next Guides:

Getting to Know Arduino : Part 2 : Hello, Again!

Getting to Know Arduino : Part 3 : Taking your Temperature

 

I recorded a video to introduce the Arduino UnoArduino Uno and how to get started with it. The premise was that you didn't need to add anything extra, except for an A to B USB cableA to B USB cable (always check the type you need for the Arduino you have) because although you can connect an external power supply it can be powered purely from the USB, and you could get code running with a few simple steps on Microsoft Windows to make an LED (Light Emitting Diode) start to flash on your board.

image

The Arduino I showed in the video was a revision 3 board, there have been a few versions so far, in the image (from zenbike.co.uk) you can see an earlier version, but it nicely maps out the connectors on the board. I think in the recent version the reset button has moved, but that makes little difference overall. What it doesn't note on the image is that any socket with the ~ (tilde) symbol next to it can be used as a Pulse Width Modulation output. This is a way of having a digital signal pretend that it's analogue but typically you don't need to worry about this until you've got some hardware that you need to output to which needs it.

 

The first instruction we can make the Arduino perform is to flash an LED, which is often considered the "Hello, World!" of getting started. The example code 'Blink' will do this for you, it flashes the LED marked 'L' on the board. This LED is also linked up with the breakout pin '13' like many connections on the board, some go through components and others do not, but they ultimately connect to the ATMega328 micro-controller processor on the board, which is the brains of it all.

 

We'll need to tell the Arduino what we want it to do and for that we can use the Arduino Integrated Development Environment (IDE), this environment contains a text editor and a console window which shows you any error messages and how successful the software has been when communicating with the Arduino. You can get the IDE for more than just Microsoft Windows, there are Mac OS and Linux variants. You might want to check your package manager and software repository for whether or not there is a version pre-packaged for your version of Linux. For example you can use apt-get on Ubuntu to "apt-get install arduino" from a terminal.

 

It's often best to get the latest non-beta version of the Arduino IDE, but if you have a board that is newer then usually this isn't supported in the 'stable' builds and a beta or nightly build is required.

 

After installing the Arduino IDE in Microsoft Windows, you'll need to connect your Arduino Uno if you haven't already. It may help to reconnect it so that it re-detects the device and installs the driver. Then you can run the IDE. To be able to upload code to the device you will need to know what COM port it is running on.

 

To do this, open your Start menu, navigate to Control Panel, once the window appears, open System and then navigate around the tabs/options until you find Device Manager. With this window open, click the + symbol next to "Ports (COM & LPT)" and the Arduino should be listed along with its COM and a number.

 

In the IDE, go to the Tools menu and then expand Board and choose your Arduino, then do the same, but go to Serial Port and choose the one that it stated in Device Manager.

 

Now to get the LED flashing, choose the File menu, go to Examples and then 01.Basics, under this menu navigate to Blink. To get this running on your Arduino you can now either click on the arrow next to the tick icon or choose the Sketch menu and click Verify/Compile. Now the 'L' LED on your board should be blinking!

 

Feel free to change the code, copy and paste bits to see what works and what doesn't.

 

This will open a new window with the following code in it:

 

/*
  Blink
  Turns on an LED on for one second, then off for one second, repeatedly.

  This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {        
  // initialize the digital pin as an output.
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);               // wait for a second
  digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);               // wait for a second
}
       

 

This is what is referred to as a 'sketch' in IDE terms, however it is actually using a low level programming language called C++ which has been around for a notable amount of time, most of the software you use is written with C++ including Microsoft Windows and parts of Linux.

 

Line 01 and 06 in the code uses text that the IDE recognises as a special arrangement so that it knows to ignore anything typed between them (it denotes that whatever is between them is a comment. On line 08 it shows the line starting with a similar arrangement that means to ignore that entire line as a comment.

 

int led = 13;
       

 

This line is literally mathematical, it could be said that programming is inherently mathematical because processors are just doing calculations and moving numbers around. So this line in particular is declaring that the english word, led is a certain type of variable (kinda like a bucket that can only contain something of a particular thing and its contents can vary) and that is called an integer, which means a whole number. As opposed to a number with a decimal (or a real number). We're then making the contents of the variable (or bucket) equal to the number 13. What then terminates the line is a semicolon and this is required by the IDE to know that we're finished putting commands on the line.

 

The IDE, or specifically the part of it that changes our near-english (sketch/programming) into a language that the Arduino can understand typically operates on a line by line basis, which is like how old typewriters used to work where by you normally couldn't go back and change what you had just created/read and had to continue (probably a bad analogy).

 

void setup() { }
      

 

The setup declaration is called a function, anything within { } is processed by the IDE, 'setup' is a reserved name for the function and it means that it is ran before anything else within the sketch. Like the variable led is of a type int, the setup function is of a type void. We don't have to worry about that for now. pinMode() is another function that is referred to and you can read up about it.

 

void loop() { }
      

 

The loop function is another reserved name that means anything within { } is ran again from the first { when it reaches the last line or instruction before the final }. The speed of this is governed by how fast the microprocessor, for example the ATMega328 can get through the instructions per second. The digitalWrite() and delay() functions can also be read up about on the Reference section of the Arduino site.

 

Hopefully you have found this useful to get started with your Arduino and it has introduced you to some new concepts for programming for micro-controllers. The best way to learn is trial and error, so don't be afraid to mess around with the code or read up about it.

 

If you have any questions, problems or otherwise please leave a comment! You can also find more information in The specified item was not found. community group!

  • Sign in to reply

Top Comments

  • cstanton
    cstanton over 11 years ago in reply to Former Member +5
    Yep. SPI is broken out onto the header sockets and also the ISCP header (one of the block of 6 pins). You can read more here: http://arduino.cc/en/Reference/SPI and there's a schematic for the Uno R3 here…
  • mcb1
    mcb1 over 11 years ago +4
    Nice work. I bet the newbies here don't search for it and still ask, but at least there is a good place to point them to. Mark
  • Former Member
    Former Member over 11 years ago in reply to cstanton +3
    Thank you for the very prompt and helpful response. I'll probably use my Rasberry Pi for experimentation and prototyping and then transfer to Arduino for a more permanent solution.
  • teprojects1
    teprojects1 over 8 years ago

    Hey dear,

    thanks for this tutorial which you have uploaded in the series, it's really help out me because now I am able to understand how to work with arduino before this I don't every understand how can we operate this, thanks once again.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 10 years ago in reply to mcb1

    Did you search for it when you were a newbie?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • clem57
    clem57 over 10 years ago in reply to Former Member

    This is true for RPI, but one thing stands out. If I wanted real time execution, I could use an external clock  chip programmed to interrupt a little before the event and get almost real time execution. This is better than my PC Windoze.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 11 years ago in reply to jw0752

    Thanks John.

     

    The example is just to detect when the button is pressed as we ignore when it released.

     

    However the principle of time checking is the same.

    Always remember to subtract from the larger number and the rollover at 49 + days will work out okay.

     

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • jw0752
    jw0752 over 11 years ago in reply to mcb1

    Thanks Mark, I always enjoy the clarity of your explanations. I am studying the logic of your button press program and will test it out tonight when I am in my shop. I like to understand the progam flow and then for good mesure I like to mock up a physical test.

    John

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube