Printed from www.nzmeccano.com
Introducing the Arduino Microcontroller
(Author: David Couch)
Introducing the Arduino Microcontroller
by David Couch, Nelson, New Zealand
Version 1.4 23 January 2019
Figure 1 The Arduino Mega, the largest member of the Arduino microcontroller family
The combination of Meccano and computers has many exciting possibilities: remote controlled models, automated models for exhibitions, game-playing and puzzle-solving machines, robots and so on. Unfortunately many Meccano builders have the impression that using computers requires a lot of technical knowledge of electronics and computer programming. That may have been true twenty years ago, but things have changed a lot. In these documents I will explain how you can obtain a computer and use it to control your Meccano models, with no knowledge of electronics and with the programming being much easier than you might have thought.
Complete microcomputer systems are now available in the form of a small board, in size somewhere between a credit card and a playing card (Figure 1). The most suitable kind for use with Meccano are microcontrollers – microcomputers specially designed to connect to motors, switches and many other devices. They have become very inexpensive, with a basic microcontroller costing as little as £3 or $NZ5 - the price of a cup of coffee. There are several microcomputer systems available which could be used to control models. I recommend the one called Arduino because
- It is specifically designed for the job, as a microcontroller.
- It is inexpensive.
- There is a large amount of help and support available, in the form of example programs, books, on-line tutorials, forums etc.
- There are many devices available to connect to the Arduino, providing every imaginable kind of function.
- These devices provide all the electronics you need. There is no need to build electronic circuits, and connecting the computer to your model is no more difficult than connecting a motor to a battery and a switch.
- Programming the Arduino is easy. Devices come with software libraries which do all the hard work for you, so that the control of a motor, for example, is reduced to just two simple commands to set its direction and speed.
Getting started with the Arduino
However much experience you have with computers, a good way to get started with the Arduino is to buy a starter kit or experimenter’s kit. The kit contains an Arduino microcontroller and a large collection of devices such as LEDs, light sensors, seven-segment displays, push buttons, and a breadboard for building circuits without soldering. A manual leads you through the construction of simple circuits and the programming of the Arduino to control them. By the time you have finished all the examples you will feel quite confident about installing the Arduino in models and programming it. Although I have a background in information technology, I found that a kit like this was a revelation, as I saw what can be done with the little computer and how easy it is to do it.
In New Zealand, kits can be found on TradeMe, at prices starting from $45. One that looks suitable is the "complete" kit from WMG1 at $75. In the UK, a suitable kit can be found here, costing £39.99 with VAT. Many different kits are also available from AliExpress.com, with prices ranging between $US25 and $US50. One example is here. Although these Chinese kits are of good quality and contain all the components you will need, their instructions tend to be rather poor, and you may have difficulty with them.
There is some advantage in buying a kit with an Arduino Mega, as this version of the Arduino provides much more capability for only a small extra cost. You will be able to use the Arduino and several of the other components in future projects.
Buying and building your Arduino
Whether or not you buy a starter kit, the next step is to buy the other components you need and put them together. My second document, Buying and Building an Arduino System, explains how to do this.
The Arduino is programmed through a software development environment in the form of a program named Arduino, which you can download from the Arduino web site and install on a Windows PC, a Macintosh or a Linux system. It consists of a text editor for creating and modifying programs, a compiler to convert your program into code that the Arduino can execute, and a loader to load the program into the Arduino via a USB cable. It also provides lots of example programs and a place to store your own and imported programs.
I do not intend to write an introduction to Arduino programming as there are many excellent ones already available. A starter kit provides one very gentle way of getting started. Another good way is to load and run some of the example programs provided with the Arduino software, and then read, understand and modify them. My companion document lists several other resources to help you get started.
I have written these documents to share my knowledge and experience of the Arduino microcontroller with other Meccano builders, in the hope that they will be encouraged to start building models incorporating the Arduino. I have taken much care in the writing of the documents, but I cannot take responsibility for errors or misunderstandings. I am publishing them on the New Zealand Meccano web site so that I can make additions and corrections as they are required. I encourage you to send me your comments, corrections and questions. My email address is firstname.lastname@example.org
Frans Dullemeijer (at 11:18am, Tue 17th Jan, 17)