Getting Started with Arduino

Discussion in 'OCAU Content' started by Agg, Mar 19, 2017.

  1. Agg

    Agg Staff Member

    I recently started playing around with Arduino and I've found myself quite addicted to these little projects. It's an inexpensive and fun way to learn electronics and device programming. This article will cover the process by which I got started, and will hopefully provide a quick introduction for other people who aren't sure where to begin. The world of Arduino is huge, and this article will only scratch the surface, but at the end I will provide a "where to from here" section with more links and info.

    One night recently I was chatting on IRC about toys or kits that would be fun to explore with my kids over the school holidays, and to encourage their interest in technology and engineering. OCAU member Quadbox suggested the Sparkfun Inventor's Kit and, in a late-night impulse buy, I ordered one. More accurately, I ordered the slightly cheaper Special Edition which temporarily exists due to the normal plastic case not being available. At this point I wasn't really sure what I was getting into, but the general idea of a solderless electronics/programming kit sounded interesting. Soon enough I had the red cardboard box in hand.

    [​IMG]

    The core of this kit is the Arduino Uno. Arduino is an open-source hardware and software platform which started back in 2005. It's a good entry point for people wanting to learn about electronics and programming devices, but can be used for all kinds of real-world projects. There is an enormous user community and a huge amount of information online to help you learn how to use Arduino and build your projects. The Uno is a specific model of Arduino board, and is the board most people begin with. Other Arduino boards are available if you need more ports, or a smaller footprint, or more CPU power or memory, etc. To be strictly correct, the Sparkfun kit includes their "RedBoard", which is a clone of the original Arduino Uno.

    [​IMG]

    Also included in the kit are a heap of other goodies, including a printed manual. I should note at this point that I am not exclusively recommending the Sparkfun kit. It seems fine, but there are many other options out there. Other companies like Adafruit, Freenove, the official Arduino.cc organisation and Australia's own Freetronics have their own well-documented kits, but you can also get grab-bags of goodies from places like eBay or AliExpress, or you can simply buy the specific individual bits you need for a particular project. There are many guides and videos on the net about projects ranging from trivially simple to very complex.

    I do think a kit like the Sparkfun Inventor's Kit is a good place to start, because at first you don't really know what you need. Having a variety of goodies arrive in one box makes it easier to get experimenting. Be warned that you will almost certainly end up ordering more bits and bobs as you go along, because these little kits are quite addictive. Fortunately the bits and bobs are usually not very expensive.

    [​IMG]
    [​IMG]

    There's too many bits included to list here - check the photos. The manual in particular is excellent. It takes you step by step from basic projects to more complex ones, with very clear diagrams and explanations of what to expect, what to do when things don't work, and what is being demonstrated by each project. My only complaint is that the book isn't ring-bound, which would let you rest it flat on a table while both your hands are busy building the projects.

    [​IMG]
    [​IMG]

    The basic idea of the projects is that you connect the Arduino Uno to sensors, LEDs or other components, using plug-in wires on a breadboard - no soldering required. You then use your PC to upload a program to the Arduino Uno via USB, which tells it what to do with the components. For example, you could simply tell it to blink an LED connected to one of its ports, which is the first project in the book.


    Each project in the Sparkfun manual has a program associated with it. You download them in an archive from their website and then you can upload them to the Arduino Uno. There is something very satisfying and addictive about seeing the project work, even if it's as simple as blinking an LED. If you're like me, you start tinkering immediately, making the LED flash faster or slower, or at a random value. What if I add a few more LEDs?


    On the software side, the Arduino IDE is a pretty decent editor, with the usual features like syntax highlighting and quite verbose error messages. If you are familiar with C or C++ programming already you will feel right at home, but if not, the book and online guides will get you going soon enough. There's also a tonne of sample code out there to borrow from.

    [​IMG]

    Generally what you do in the programs, or "sketches" as they're called, is monitor an input, decide what to do, then send a signal as output. For example the second project in the book has you reading the value from a potentiometer (a variable resistor), and using the value to control the brightness of an LED. Once you have a few projects under your belt, you start to combine them. What if the value of the light sensor is used to control the colour of the RGB LED? Or if the heat sensor controls the pitch of the tone coming from the speaker? It really feels like computing in its purest form. Input, processing, output.

    If you remember, I originally got this kit as something to do with my kids. Will, my 10yo son, took to it very quickly. I will say that it's worth going through and installing the various USB drivers and so on beforehand, as that's not very interesting to kids. I also took the precaution of building the first project one evening by myself to make sure everything worked before getting the kids involved and repeating the build the next day. But very soon he had grasped the concept and was even editing the programs to see the result of changing delays etc. In fact on one day of the school holidays when he wasn't allowed to stare blankly at the TV or his phone, he took it upon himself to build the last project in the Sparkfun book, a "Simon Says" type game. In that game, an ever-growing sequence of sounds and LEDs light up, and you have to reply by pushing the correct colour buttons in the correct order. Once you get up to 5 or 6 steps in the sequence it becomes quite tricky to remember. Anyway, after he'd built it and uploaded the program he played the game for quite a while - partly because the game is genuinely quite fun, but also because he was marvelling at the fact he'd made it himself.

    [​IMG]
    [​IMG]

    There is a lot to do in the SparkFun kit - 16 projects in all - but they're all fairly basic to teach you the fundamental concepts. However, there's a world of other components and project ideas out there. On the next page, we take a few steps beyond the basic kit.
     
    Last edited: Mar 19, 2017
  2. Agg

    Agg Staff Member

    So far we've been playing with the Sparkfun Inventor's Kit. The real magic happens when you realise what other gadgets are available to connect to the Arduino. There are "shields" which attach to the top of the Arduino board and give you additional functionality, or you can just use the jumper wires. You can connect it via WiFi, Ethernet or Bluetooth. You can connect a GPS module so it knows where it is in the world. You can make it write to SD cards, send texts, operate stepper motors, linear actuators, LCD screens or pretty much anything you can think of. They don't have to be Arduino-specific components, as you are entering the world of "real" electronics here. Googling or searching YouTube for "cool arduino projects" leads you down a rabbit-hole which never ends. So, after a bit more late-night browsing and a surprisingly reasonable amount of money, some more bits arrived to play with.

    [​IMG]

    One of the more interesting components was a GPS module. I had to solder the provided pins in place, which wasn't too hard - use the breadboard to hold the pins in place while you solder. Then it was trivially easy to connect the 4 pins required (power, ground, transmit and receive) to the Arduino, then use the TinyGPS++ library to talk to the GPS. In no time at all I had the unit reporting its position via the USB port, and also displaying it on the LCD screen from the SparkFun kit. I'm not by any means an electronics expert and I was amazed at how easy it was to get it working.

    [​IMG]

    Over the next couple of weeks I built that project into a small jiffy-box, with the idea of it being a "reverse geocache". Essentially, when you turn it on, it tells you how far it is from where it wants to be, and how much time you have left to get it there. The game is to, without being given specific directions, work out where it wants to be and try to get it there within the time limit. Unfortunately it does look quite a lot like a bomb at the moment:

    [​IMG]

    I also ordered a Pro Micro, which is similar in abilities to an Arduino Uno, but in a smaller form-factor - and costs about $2 delivered. I had to solder the pins on, which wasn't as tricky as I was expecting. Soon enough we had the Pro Micro talking to the GPS and reporting its position via the USB serial port:

    [​IMG] [​IMG] [​IMG] [​IMG]

    Then, err, some more bits arrived, in the form of a Freenove Ultimate Starter Kit. Did I mention these things are quite addictive? I really must cut down on my late night Arduino browsing.

    [​IMG] [​IMG]

    This kit is quite cool too. It doesn't have a printed manual, but has one you can download and it's quite a bit more comprehensive than the Sparkfun one. It also includes their version of a Uno, and some cool sensors and displays. So we built this thing which makes a light move faster or slower depending on how far away it senses an object to be:


    The chips on the left of the breadboard in that video aren't doing anything, they're just there to stop them being damaged floating around in the box of bits.

    I could go on, but I think you get the picture. Playing around with Arduino has really re-kindled my interest in electronics and programming. I'm a bit late to the party, but now that the platform is a few years old it really works well, has lots of documentation and sample code available and a big community for support. A lot of fun and education can be had by adults and kids for not too much money, and if you want to get into more serious projects, Arduino will help you do those as well.

    Where to from here?
    A good place to start is the official Arduino page. While the hardware and software are open-source, use of the Arduino name and logo has some restrictions. If you want to buy official boards and thus support the original creators of Arduino and fund their future development, buy from them. But there are many perfectly fine and legal cheaper clones out there. The official page also has a FAQ and lots of tutorials etc.

    I created an Arduino beginner thread on OCAU which has turned into a useful resource and general Arduino discussion thread, so feel free to share your projects and ask questions in there.

    One enthusiastic Australian supplier is Freetronics, who make a starter kit you can probably rush out and buy today from your local Jaycar if the bug has bitten you hard. Speaking of which, Jaycar have a dedicated Arduino page. Other vendors recommended to me include Core Electronics (Australia), tronixlabs (Australia), Adafruit (USA), Freenove (China) and Tayda (Thailand).

    Sometimes you just need one bit to complete a project, so it's nice to be able to get things immediately in Australia. But if you're willing to wait the several-weeks shipping time from China, you can get components a LOT cheaper on eBay and AliExpress, who are essentially an eBay for Chinese manufacturers. If you search on AliExpress for "arduino" and sort by cheapest price, there are many interesting bits and bobs for under $1 or $2 AUD shipped.

    There's a huge amount of tutorials and documentation out there. Pretty much any project you can think of will already exist in Google, with a tutorial and code to borrow. Jeremy Blum has some good Youtube tutorials, but search and you will find many more. Instructables have lots of project guides and a free Arduino class. If you haven't got the hardware but want to play anyway, circuits.io have an online lab simulating Arduino boards so you can test projects and programs.

    Phew! Hopefully all this has encouraged you to have a go with Arduino - it really is a lot of fun. Feel free to jump into this thread on OCAU if you have any questions or want to show off your projects!
     
    Last edited: Mar 19, 2017

Share This Page