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.9  20 May 2020

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 for parts bought in the UK or USA is around £40 in the UK or $100 in New Zealand. If you buy the parts from AliExpress.com the total cost is about $US14 ( £11 or $NZ20).

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 a starter kit, 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. A good place to buy it in the UK is Hobby Components. The price, including the required USB A to B cable, is £12.50 including VAT. Alternatively you can buy it from AliExpress.com for about $US7.50. An example is here.

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. Arduino 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 version 2, as it is the only shield I have found that can control four DC motors or two stepper motors. It is shown in Figure 1. It can be obtained from Adafruit at a price of $US19.95 (about £12). I recommend also obtaining a set of stacking headers, which will need to be soldered to the shield.

Bargain sites such as Ebay offer low-price clones of the motor shield. However many of them are clones of the version 1, which uses the L293D chip and is obsolete and of no use, because the required software library is no longer available. Version 2 clones, which use the TB6612 chip, can be found on Ebay UK, Ebay Australia, Ebay USA and AliExpress, along with a lot of version 1 clones. If these links do not work, browse to the site and enter the search word tb6612. This will display several version 2 clones, along with other things. Figure 1 shows what you are looking for. Pick the cheapest one, as they are all the same. The clone has the headers installed and so it does not require soldering. You will need to download the free software from the Adafruit web site, as described below.

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 AliExpress.com The price is $US1.27 (about £1). The shield comes as two separate boards, which will be plugged into the Arduino headers on either side. Its headers pass through the SCL and SDA signals, which were added in the R3 versions of the Arduino and are required by the motor shield.

Assembling the Arduino system

Installing the headers in the Adafruit 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. The shields from Ebay and AliExpress have stacking headers installed and do not require any soldering.

Putting the system together

First plug the terminal shield into the Arduino, taking care that the headers are aligned correctly and no pins are bent. Figure 2 shows a two-part  shield installed. Then plug the motor shield into the terminal shield. Your system is now complete, as shown in Figure 3.


Figure 2 The Arduino with the terminal shield


Figure 3 The complete system



If you buy the original Adafruit components described above you will need to do some soldering. 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) or here (AliExpress.com). No doubt you will have more use for the iron when you come to connect motors, LEDs etc. 

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) or here (AliExpress.com).

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 4 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 4.


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 5 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 5 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.

Programming the Arduino

If you bought a starter 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. Several are available from Amazon.
• 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


Stephen Westmoreland      (at 3:18pm, Wed 30th Sep, 20)

I did, thanks bob t.

bob t      (at 7:46am, Wed 30th Sep, 20)

Stephen, Why don't you email David directly, his email is just above. Communications are not brilliant using this method due to spammers. Or join us on Rust Bucket Forum and chat about Arduido etc.

Stephen Westmoreland      (at 7:33pm, Tue 29th Sep, 20)

Hi David
What do you think of the Complete Ultimate Starter (MEGA 2560 R3, stepper motor etc) from Fishpond $176 or Arduino K000007 Starter (UNO board rev 3, servo motor etc) $174.42 from element14? What does UNO mean? I am a Meccano modeller and have asked for a Christmas present around $200 and like an Arduino set that has all accessories - breadboard, advice and all the sensors.

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:

The Arduino Sketch 
and how to upload a Youtube or Vimeo video to the Gallery 
(Paulo Kroeff de Souza)
"Homemade" Screwed Rods
(Paulo Kroeff de Souza)
The Meccano driving band problem
(Paulo Kroeff de Souza)
Meccano Cord Reproduction
(Paulo Kroeff de Souza)
Substitutes for parts 142 and 155
(Philip Drew & Richard Smith)
Midlands Meccano Guild
105th Model Report 
92nd Model Report 
(Neil Bedford and John Rogers)
Midlands Meccano Guild
104th Model Report 
91st Model Report 
103rd Meeting Model Report 
by Peter Stuart, Meccano Modellers Association Sydney Inc 
(Richard Smith and Neil Bedford)
Midlands Meccano Guild
102nd Meeting Model Report 
(John Rogers & Colin Bull)
Midlands Meccano Guild
101st Meeting Model Report 
Spanner Challenge 
(John Rogers and Neil Bedford)
Midlands Meccano Guild
100th Meeting Model Report 
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 
Not many in this condition I'll bet! 
Some hints and tips 
 View all | Chat | Models | Hints and Tips | Opinion | Reviews | Mine