Home | Links | Contact |

Printed from www.nzmeccano.com

Top Home Bottom

Buying and Building an Arduino System

(Author: David Couch)

Buying and Building an Arduino System

by David Couch, Nelson, New Zealand

Version 1.5  3 December 2015

This document describes a microcontroller system that is suitable for controlling Meccano models. It consists of an Arduino microcontroller board, a motor control shield and a terminal shield. In the process of designing this system I have bought and tested several components of each type, from several suppliers. I have come to the conclusion that the system described here provides all the functions you are likely to need at the lowest cost. The total cost is around £40 in the UK or $100 in New Zealand.

What is a shield?

A shield is a circuit board which piggybacks on the Arduino board. It has male headers, or pins, which plug into female headers, or sockets, on the Arduino board, making all the required connections. Figure 1 shows an Arduino Mega with a shield plugged into it. A large range of shields with many different functions is available.

What is a motor shield?

Figure 1 An Arduino with a motor shield

The Arduino cannot control motors directly, as it cannot provide enough power or reverse the direction of a motor. A motor shield has all the circuitry required to independently control the direction and speed of several DC motors or stepper motors. The motors are connected to the shield through small screw terminals.

What is a terminal shield?

The Arduino has many input and output connectors in the form of pins, which do not make convenient or reliable connections to external devices. A terminal shield or screw shield provides a small screw terminal connector for each pin, so that wires from switches, potentiometers, LEDs etc can be easily and securely connected without soldering.

What can I connect to the Arduino system?

If you build the system described here, you can connect all of these:

Motors: four DC motors or two stepper motors can be controlled, with variable direction and speed. More can be added if a second motor shield is installed.

Servos: two standard or continuous rotation servos can be connected through the motor shield. Many more servos can be controlled by the Arduino with some additional circuitry.

LEDs (light emitting diodes): up to 12 LEDs can be connected and individually controlled through the terminal shield, with variable brightness if desired. Many more can be connected with additional circuitry. Larger groups can be controlled using the motor connections.

Switches: these can be hand-operated toggle or push-button switches, or microswitches, tilt switches or magnetic switches activated by the model. Up to 12 switches can be connected and read through the terminal shield. Many more can be connected with additional circuitry.

Joysticks and Potentiometers (variable resistors): up to six potentiometers can be connected and read through the terminal shield. More can be connected with additional circuitry. A joystick usually contains two potentiometers and possibly one or more switches. Up to three joysticks can be connected.

Relays: if relays are required to control high-current or high-voltage devices such as lamps, a four- or eight-relay module can be purchased and controlled by the Arduino.

Details of how to physically connect devices to the Arduino are given in my document Arduino Programming Reference. If you are interested in the extensions and additional circuitry mentioned above, please send me an email message.

What to buy and where to buy it


If you have bought an experimenter’s kit with an Arduino Mega, as I recommend in my introductory document, then of course you already have this.

The Arduino comes in several different formats, with different capabilities. The Uno is the standard entry-level Arduino, and probably the most popular. However, I recommend the Mega, the largest Arduino, because for just a small extra cost it offers much more memory and many more I/O pins.

The current model is called Arduino Mega 2560 R3. The best place to buy it is Hobby Components in the UK. The price, including the required USB A to B cable, is £12.49 including VAT.

The Arduino you buy from any source may be an original, or a clone or “compatible”. You should not be concerned about buying a clone. The Arduino is an open design, which other manufacturers are free to copy. Clones are not pirated or unethical, and as far as I know they are functionally identical to the Arduino originals.

Motor shield

I recommend the Adafruit Motor/Stepper/Servo Shield for Arduino V2, as it is the only shield I have found that can control four DC motors or two stepper motors. Version 2 of this shield has recently been released, and is definitely preferable to Version 1. The only place where Version 2 can be obtained at present is Adafruit. The price is $US19.95 (about £12). Several other web sites offer motor shields which are clones of either the Adafruit Version 1 shield or the Arduino motor shield, which can control only two motors.

Terminal shield

I recommend the Proto-Screwshield R3 from Adafruit. It costs $US14.95 (about £9) and comes as a kit which requires soldering.

An alternative which does not require soldering is a terminal shield from Tinysine Electronics. The price is $US7.95 (about £4.70). The shield comes as a single board with a groove down the centre. It needs to be snapped at this groove into two separate boards, which will be plugged into the Arduino headers on either side. It has very long pins, which make it sit high above the Arduino. I cut 5 mm off each of the pins, so that it sits snugly on the Arduino headers.

Assembling the Arduino system


If you do not already own a suitable soldering iron, I strongly recommend that you buy a soldering station such as the one shown here (UK) or here (NZ). No doubt you will have more use for the iron when you come to connect motors, LEDs etc.

Installing the headers in the motor shield

The Adafruit web site gives instructions for installing headers, terminal blocks for the motor connections and headers for servos and the power jumper. However with the latest kits all you need to do is to install the four strips of headers around the edge of the board. These have been left so as to give you the choice between simple male headers and stacking headers, which allow you to stack another shield on top.

Please note the following points:
• On the side with the digital pins you need one 8-pin header strip and one 10-pin strip, which includes the SDA and SCL pins. See Figure 2.
• On the other side, one 8-pin and one 6-pin strips are shown. Replace the 6-pin strip for the analog pins 0 to 5 with a 4-pin strip and solder it into holes 0 to 3, so that there are no pins in the analog 4 and 5 holes. This prevents the motor shield from interfering with the operation of the analog 4 and 5 pins on the Arduino board. See Figure 3.


Figure 2 The digital pin side of the motor shield, showing the ten-pin header


Figure 3 The analog pin side of the motor shield, showing the four-pin header


Putting the system together

First plug the terminal shield into the Arduino Mega, taking care that the headers are aligned correctly and no pins are bent. Figure 4 shows the two parts of the Tinysine shield installed. Then plug the motor shield into the terminal shield. Your system is now complete, as shown in Figure 5.


Figure 4 The Arduino with the terminal shield


Figure 5 The complete system



Getting started with the Arduino software

Instructions for getting started with the Arduino software are here. You will download and install the Arduino environment on your computer, connect the Arduino to it, install the drivers, launch the Arduino application, open an example sketch (program) called blink, upload the sketch to the Arduino and see it run.

Installing the Adafruit motor shield software

Next download and install the software for the Adafruit motor shield, following the instructions here.

Supplying power to the Arduino

There are several ways to supply power to the Arduino.

USB cable

The USB cable that you use to connect the Arduino to your PC to upload sketches also provides power to the Arduino. It carries enough power to run the Arduino itself and a few attached devices such as an LED, a servo or even a motor for running the example sketches. It cannot provide enough power to run motors that power models.

Once a sketch has been uploaded to the Arduino, the USB cable can be disconnected, and the sketch will be retained in the Arduino’s flash memory, even when the power is turned off. The sketch will start to execute whenever the Arduino is powered on or reset.

Power supplies

For static models I prefer to use power supplies of the type which plug into a wall socket, known as plugpacks or wall-warts. Choose a regulated power supply, as unregulated ones can output a much higher voltage than their rating. The most useful type has the output voltage selected by a switch, usually with a range of 3 to 12 volts. An example can be seen here (UK) or here (NZ).

The power connector on the Arduino is a 2.1 mm centre-positive coaxial power connector or barrel connector, which is the type of connector commonly provided with plugpack power supplies. The input voltage can be in the range 7 to 12 volts, but it is best to use 7.5 or 9 volts. If you are using a power supply with interchangeable connectors, make sure the 2.1 mm barrel connector is oriented for the correct polarity, i.e. centre positive.

Figure 6 The Arduino system powered by two plug-pack power supplied

The motor shield can be powered in two different ways, selected by the small jumper supplied with it, which can be placed on the two-pin header next to the power terminals. If a single power supply is used, the jumper is installed, and the supply powers both the Arduino and the connected devices. However, this is not recommended for motors, as motors can cause interference and erratic running of the Arduino. It is better to connect a second power supply, whose voltage can be in the range 4.5 to 13.5 volts, to the power terminals on the motor shield. In this case the jumper must be removed.

If the second power supply has a barrel connector, you can connect it to the terminals using an adapter like the one shown in Figure 6, which was bought from Jaycar.


For vehicles or for exhibition models it may be preferable to power the Arduino with batteries. Again there is a choice between using a single battery, with the motor shield power jumper installed, or two separate batteries, with the jumper removed. The battery used to power the Arduino should be a 7 to 9 volt one, consisting of six AA size or larger cells. Nickel metal hydride (NiMH) rechargeable batteries are suitable, though they give only 1.2 volts. For the motors you can use any battery of your choice from 4.5 to 13.5 volts. A sealed lead-acid battery will probably give the longest running time.

Figure 7 The Arduino system powered by two batteries

To connect a battery to the Arduino, instead of using the barrel connector you can connect wires from the positive side of the battery to the VIN terminal, and from the negative side to the GND terminal. Figure 7 shows the Arduino with a 7.2 volt (6 cell) NiMH battery connected to the VIN and GND terminals, and a 4.8 volt (4 cell) battery connected to the motor shield power terminals. Battery boxes can be bought cheaply from electronic suppliers such as Maplin.

Programming the Arduino

If you bought an experimenter’s kit you will have already learned quite a lot about programming the Arduino. Whether or not you have done this, you should investigate and use all of these resources:
• A book on programming the Arduino. A good book can be downloaded free from here.
• The example sketches provided with the Arduino and Adafruit environment software which you have installed. In the Arduino program, in the File menu, click Examples to see the various categories of examples. It is a good idea to load and run some of the example sketches, and you can learn a lot from reading and modifying them.
• The Arduino language reference. In the Arduino program, in the Help menu, click Reference.
The Arduino web site, which has loads of information and support.
The Adafruit web site. Information on the motor shield, including the library reference, can be found here. (See the links on the left of the page.)
• My document Arduino Programming Reference, which provides a convenient reference for the code needed to control the various devices you are likely to connect to your Arduino.


The Arduino site


Sites with Arduino boards, shields and accessories

These are just a few of the many sites which offer shields and other devices for use with the Arduino. Browsing these sites will give you an idea of the great variety of controllers and sensors available, and how cheap they can be.
http://www.ebay.com (Use the search facility.)


I welcome additions, corrections, comments and questions related to the Arduino and Meccano. My email address is david.couch46@gmail.com


If you have any interesting information or comments about this page, please add them here:

Your name:
Your message:
Security check: (Please type in the text to prove you're a person!)
Login status:  You have not yet entered your user name and password. You cannot create or edit documents until you do.
Enter your user name and password to log in

Remember me

If you click on the box marked 'remember me next time', you will not have to log in again on this computer for three months.

If you don't have a user name yet, please click here

On this page...

Latest documents:

A G gauge model 
(Colin Bull & Richard Smith)
Midlands Meccano Guild
99th Meeting Model Report 
98th Meeting Model Report 
97th Meeting Model Report 
(David Couch)
The Little Tram
An introductory Arduino project 
(G. Eiermann and M. Schild)
A Short History of MARKLIN Metall
96th Meeting Model Report 
83rd Meeting Model Report 
82nd Meeting Model Report 
Picks up three golf balls 
(Roger Marriott)
Midlands Meccano Guild
95th Meeting Model Report 
The Spanner Challenge 
94th Meeting Report 
(Andre Theberge)
Meccano Segway
(Andre Theberge)
A Meccano Segway
Arduino code 
(Andre Theberge)
A Meccano Segway
Assembly instructions 
(Michael J. Walker)
Meet the new MMG President
Geoff Wright 
The Spanner Challenge 
(Michael Walker)
Midlands Meccano Guild
93rd Model Report 
Report by Michael J. Walker. 
92nd Model Report 
(Stan Knight)
Minimal Meccano
Pocket Meccano Sets of the 1970s 
Little Lever, Bolton 
The Spanner Challenge 
91st Model Report 
(Bob Thompson)
Back to the beginning
Shop Display Model 
90th Meeting Report 
(Old Blue Gold)
Getting Old
A screwy story 
The Spanner Challenge 
Model report written by Michael J. Walker 
76th Meeting Report 
Exhibition in Nelson, New Zealand 
(Barry Gerdes)
Meccano Radio
How to flatten  
(Rod Socket)
Dear Mrs Spanner
Survival techniques for the Meccanoman's wife 
(Stan Knight)
The Top Ten Tools
Indispensable Tools for the Meccanoman 
A call for help 
The Spanner Challenge 
For small brass and nickel parts. Also for stripping paint and rotted zinc plating. 
(Stephen Heafield)
Waterslide Transfers
Refurbishing 0 & 00 Aero Models 
Construction details 
or Put Your Hammer Away 
Mobile Morris Crane from 1968 MM 
Bert Love's Blocksetter in colour 
The dangers of internet auctions 
(Rob Thompson pp Terry Bullingh)
BlockSetter Tower
Built by Terry Bullingham 
(Rob Thompson pp John Reid)
Captain Robert Falcon Scott
1912 Polar Sledging Party 
(Niels Gottlob)
Bucket Wheel Excavator
Transcribed from typed document with photos 
Selected Spanner messages 18th to 24th January 
Selected Spanner messages 11th to 17th January 
Selected Spanner messages 4th to 10th January 
(Norbert Klimmek)
Hulett Ore Unloader
A 1 to 32 Scale Model 
(Joe Attard of Malta)
A model ship
(Arup Dasgupta (ISM 652))
My E15R Motor
A repair story 
About Meccano
What is Meccano? 
Thoughts about modern Meccano 
Some hints and tips 
Not many in this condition I'll bet! 
 View all | Chat | Models | Hints and Tips | Opinion | Reviews | Mine