Getting started with Arduino! – Chapter Zero

Hello world!

Updated 24/11/2012

Please join with us as we learn about electronics and the Arduino! Together through this series of tutorials I would like to share with you a journey of learning, exploration and fun with the Arduino system, and make some enjoyable, useful, interesting, useless and practical things. These posts will be published on a regular basis, on top of the other non-micro controller posts. Instead of listening to someone talking really quickly on a video, you can read and follow through at your own pace, see examples in action, learn a great deal – and be inspired to make something of your own.

So let’s get started…

There are over fifty chapters in this series, however you should start here (chapter zero). However there is a full  index of articles is to your right, or can be found here. Once you have covered the material in chapters zero to thirteen you should be able to jump into any other chapter. During the first few posts, we will refer to the book:

and also assume a basic knowledge of electronics. For support or to have your questions answered, post your enquiry in our Google Group – a friendly place for such discussions.

If you would prefer an off-line method of learning, or would like a great book on the topic – consider my book “Arduino Workshop” – it’s the best book on the market for a complete beginner to learn about Arduino.

First of all, let’s breakdown the whole system into the basic parts. From there we can build an understanding of what Arduino is all about.

Arduino is an open source physical computing platform based on a simple input/output board and a development environment that implements the Processing language (www.processing.org). Arduino can be used to develop standalone interactive objects, or be connected to software on your computer. [1]

So, we have hardware and software. Our hardware will be a personal computer that can run the Arduino IDE (integrated development environment) software; and the Arduino itself and the electronics to go with it.

Our software is the IDE – software very similar to a word-processor, but can send the Arduino program (or “sketch”) to the micro controller. These sketches are programs that are written in the processing language – which is similar to C. These are interpreted by a boot loader – software in the chip that allows it to understand your sketch. As the Arduino system is open source, anyone can purchase a blank micro controller and put the boot loader on it, or even write their own boot loader or modify the original one.

Now for the Arduino itself. But what do we mean by that? Let’s have a look…

Arduino Uno

What we have is a microcontroller installed into a circuit board with a USB interface, a DC power socket, and many input and output lines (more about them later). Plus some LEDs for status reports, and other miscellaneous components. This board is the Uno, and uses the ATMega328 micro controller.

There are also larger, smaller, older and in the future newer boards – each different by their physical size, interface type, and available sketch and data memory. A very good improvement on the Arduino boards are available from Freetronics.

The purpose of the board is to simplify to a great degree access to the micro controller, and allow you to easily interface with inputs, outputs, add power supply, connect to a PC for programming, and talk to other circuits. However the board is more for your convenience, you can actually use the programmed micro controller in your own designs without the board. 

To summarise at this point – with an Arduino you can connect various forms of input and output, and create a program to process and respond to the inputs and outputs. For example, you could create a temperature alarm – when your room temperature rises above a set amount, the Arduino could sound an alarm.

Forms of input can include: buttons, switches, movement sensors, temperature sensors, light sensors, gas sensors (!), dials that you can turn (e.g. like a volume knob), wireless data receivers, etc. Forms of output can include: lights, noise-makers, motors, pumps, other circuits, liquid-crystal displays, etc. Basically anything that can be switched on or off, or controlled by electricity, can be controlled by an Arduino.

To make things easier, you can buy or make what is called a shield. This is an interface board that sits on top of your Arduino, and has various types of circuitry you can interface with. For example, an Ethernet network connection, a joystick for games or controlling a robot, or an LCD.

So that means with the right sketch, and the right hardware interface, and maybe a shield, you can do almost anything.

Great!

Thankfully that’s about all we need to learn at the moment. Now it is time to actually do something. You are going to need three things:

  • A personal computer running Linux, MacOS or Windows with a USB port, with Internet access. Then again, if you’re reading this – you’re on the ‘net
  • a USB cable that matches your board socket
  • an Arduino or compatible board. Most boards should come with a USB cable, check before buying.
Update – 10/01/2013: I have written these tutorials in a period spanning over two years. During this time several versions of the Arduino IDE have been published. Over the next few weeks I am endeavouring to update the tutorials so that they work with the latest Arduino v1.0.1 (or newer) IDE. In the meanwhile, you can run both v23 (old) and v1.0.1 (and more) on the same machine. Any tutorial noted as updated on 24/11/2012 or later works with the new IDE. Any questions – email john at tronixstuff dot com.

And now for the initial preparation – please install your Arduino IDE software using the instructions here. If you are running Ubuntu, here is an excellent installation guide.

How did you go? Did your LED blink? Were you mesmerised by it, staring blankly at all the blinky goodness? It’s ok, you can admit it – we all were the first time.

When working through this series of tutorials, some of the files you download will end with .pde or .ino. They’re both fine, the .pde extension was used for sketches written before Arduno IDE v1.0. You can load these and work with them as normal.

At this point I hope you realised that the Arduino can be powered by your computer’s USB port. However, if you want to use your programmed Arduino away from the computer, you will need a nice regulated plugpack or another source of power.

There is some really basic things to get started, however with respect to the Arduino creators, please refer to the book Getting Started with Arduino book until the end of page 38. You should be able to get that LED to blink on your own!

Exercise 0.1

Now let’s have some more blinky fun. Do you remember Knight Rider with David Hasselhoff? The ‘hoff drove a tricked-up Trans Am with some cool lights in the bonnet, a horizontal row with each light blinking in sequence from left to right to left…

Your mission, is to simply recreate this with your Arduino, using not one but eight LEDs. Blink them in an endless loop in the sequence 1-2-3-4-5-6-7-8-7-6-5-4-3-2-1-2-3-… with a delay of one second.

You will need:

  • Your standard Arduino setup (computer, cable, Uno or compatible)
  • 8 light emitting diodes (LEDs). Anything as long as they draw less than 40mA.
  • 8 560 ohm 0.25 W resistors. They are to reduce the current to protect the LEDs
  • a breadboard and some connecting wire
  • a camera (optional) – to document your success!

Hint – make the delay a variable so you can alter it easily.

From your original flashing LED project in the book, the digital pin 13 was used. This time, you can use digital pins 2 to 9. The hardware side is easy – run a wire from each digital output pin to the anode of an LED, then put a 560 ohm resistor from the cathode back to ground. See the diagram below:

exercise0p1

And this is what the result should hopefully look like:

And of course, here it is in action:

Now it is your turn to do something – write the code! But before you do that, plan what you want to do first (some old-schoolers would call the plan an algorithm). For example, for this exercise you might write something like…

exercise 0.1 plan

set all the pins I want to use as outputs
create a variable to store the delay duration in milliseconds
start an infinite loop
turn on pin 2, wait for delay duration, turn it off
turn on pin 3, wait for delay duration, turn it off
repeat for pins 4 to 9
then do the same thing but backwards down to pin 3
end of infinite loop

So how did you go? Did it work first time? It’s ok if it didn’t, as you learn by doing and fixing your mistakes. Remember – if you have any questions, leave a comment at the bottom of this post and I will get back to you. But to save you time, here is the sketch:

So there you have it. Today you have learned how to set up a computer to program your Arduino, and written some sketches to create outputs based on your design. Although it wasn’t that much, we have to start somewhere… but great things will follow. Like chapter one! 

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Notes:

[1] from “Getting Started with Arduino” by Massimo Banzi (O’Reilly).

The following two tabs change content below.

John Boxall

Founder, owner and managing editor of tronixstuff.com.

29 Responses to “Getting started with Arduino! – Chapter Zero”

  1. viennatech says:

    Thank you for this excellent resource for geeks like us! I received my Arduino board and component kit today and was able to successfully get the KITT flasher working in around 20 minutes. You are an amazing teacher and I’m very excited about progressing thru your lessons.

  2. Michael says:

    Thank you for these tutorials, they are extremely helpful. I could use one on the HC 05 bluetooth module too ;)

    Could the resistors in this tutorial be replaced by just one or would that cause some kind of a problem?

    Thanks,

    Michael

  3. Alfredo says:

    Excellent/simple tutorial, and much less boring than the single LED 13 blinking! lol
    I notice something, the varible is set to 100, and then says 1000ms, is that alright?
    Thank you!

  4. CT021ZA says:

    thanks ! this was a fun starting project :) …. the bug has officially bit ….

  5. Graham says:

    Hello John

    Thanks for this great tutorial, I am sure I will be visiting and revisiting your many chapters as I progress.

    In your introduction you mentioned that users of you tutorial must have a basic understanding of electronics. I have never used “resistors” and “bread boards” and my understanding of electronic theory is at non-existent. Can you recommend any good sites for basic electronic theory (like grade school level). Also, I have never programmed C, so any info about basic arduino programming commands/language would be greatly appreciated!

    Thanks,

  6. hameedullah says:

    i want a program to send massage to mobile through arduino when main power fail please help me sir

  7. R Hoff says:

    Complete noob here, if we copy and paste your sketch, do we start from line 1, and if not what character(s) tells Arduino to start processing from?
    Cheers

    • John Boxall says:

      Until you become more familiar with the sketches it would be easier to copy the whole thing, however you can disregard comment lines if you want.

  8. Guy says:

    Hi,
    As you will notice of my question,I’m a beginner.
    Can I use 220 ohm instead of 560

  9. Lin Jiali says:

    Hi, Mr. Boxall

    I have just taken up Arduino after having come across your tutorials. I have also purchased your book “Arduino Workshop” and “Getting Started with Arduino” by Massimo Banzi online from O’Reilly’s.

    I would like to seek your advice on whether the ATmega328 could be used independently (i.e. without attachment to the Arduino ONO board) after it has been programmed with the “KNight Rider” program. Also, how should the 8 LEDs be wired. I would appreciate your guidance. Thank you.

    – Jiali (from SINGAPORE)

    • John Boxall says:

      See chapter 11 to use the MCU on its own, and table 11-1 tells you which physical pins correspond to Arduino Dx pins. Then (apart from the MCU wiring) it’s just an LED and 560R resistor from each digital output you want to the GND.

  10. Lin Jiali says:

    Dear Mr. Boxall

    Thank you very much for your immediate attention. I believe now I got it: the MCU needs a minimal Arduino circuit if it is to run on its own. Am I right? Regards.

    - Jiali

  11. สัมภาษณ์ BE says:

    You should take part in a contest for one of the finest websites on
    the net. I am going to highly recommend this site!

  12. rysul says:

    hi, mr Boxall.
    I’ve an arduino due. will it effect the coding of the other chapter tutorials.
    Also need another suggestion .Do i have to know a lot about digital ckts or logic gates for learning arduino? i’m totally new in arduino or any embedded system.Don’t know about digital ckts very much.but know C programming and some elementary electronics.

    • John Boxall says:

      Hello
      Learning to use the Arduino development platform is easy, and if you already have a background in any sort of programming and some electronics – you’ll be fine :)
      However the tutorials written here will cause issue with the Due – although it is branded Arduino the onboard microcontroller has much different power-handling capablities and a lot of Arduino libraries need work to be used with the Due.
      To follow my work please use an Uno, Duemilanove or compatible board.

  13. karthi says:

    sir i want all chapters in pdf form…it’s available sir ????

  14. JMRoss says:

    If the resistors are to reduce current/lower voltage to the LED from the board, why wouldn’t they be located between the Uno board and LEDs instead of after the LEDs?

    • John Boxall says:

      The resistors reduce the current flow in the entire circuit – from the Arduino to LED to GND (and thus back to the Arduino) so you can put them before or after the LEDs.

  15. BG says:

    I think I’m gonna have fun with this.
    On to Chapter One!

  16. johnny says:

    i am able to do this one. thnks. even if this is one of the simplest proj one can do using arduino uno, still, interfacing software and hardware is something. you feel the pleasure and the fulfillment on the inside…

Trackbacks/Pingbacks


Leave a Reply

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: