To program an automated fairground ride.
A popular DT (design technology) project in schools is for children to build a fairground ride that includes some electrical components such as lights, buzzers, and a motor (with a 200:1 gear box attached).
For this task you are going to program a fairground roundabout to bring it to life.
- You will be able to use the gPiO interface for input as well as output.
- You will be able to program an input and output control system.
- You will understand how to control a motor in a forward and reverse direction.
- You will understand the need for a fail safe control.
This model needs some thought on the physical construction, but is still relatively easy to build. A basic template for the working mechanism has been provided.
You could just turn the motor on and off – but to make it more realistic (and more fun), add forward and reverse motion, lights and buzzers There should also be a fail safe switch that will stop the ride if something happens to the operator.
This is the fairground ride algorithm for the code we have used:
- When the start button is pressed:
- some lights flash
- a warning buzzer sounds once just before the ride starts to turn
- repeat 5 times
- turn for three seconds in one direction
- turn three seconds in the other direction
- the buzzer should sound twice to signal the end of the ride
- if the operator releases the switch the ride will stop.
Adding some suitable music gives the model more of an impact. Click the music player below for a short snippet of the Waltz from Carousel.
If you like this you can download the whole piece from the Code Library > Media Files
Making the Model
i) Glue the motor (and 200: gearbox) onto a short length of wood about 5cm x 5cm x 2cm (see below).
ii) Glue a pulley wheel onto the motor spindle.
iii) Drill a hole through the centre of the wood block just wide enough to take a piece of dowel so that it will turn easily.
iv) Glue another pulley wheel onto the length of dowel so that it sits just above the wood block and is at the same level as the pulley on the motor.
v) Connect the wires from the motor to one of the motor outputs on the end of the gPiO and switch it on. The mechanism should operate as shown in the video below.
Connecting to the gPiO Box
When you are connecting to the model, the red wires from the LEDs and the buzzer must be connected to the red (positive) sockets on the gPiO. The motor must be connected to the motor outputs. If you use the code shown below make these connections.
- INPUT A – Push Button
- INPUT B – Safety Switch
- MOTOR A (On side of gPiO box) – Model motor
- OUTPUTS 3,4 & 5 – Lights
- OUTPUT 6 – Buzzer
Scripts & Code
This is the Scratch Script and Python Code for this project.
If you use Flowol(TM) in your school you can download this flowchart from the Code Library. Version 4 and above of Flowol can be used with the gPiO Box, so that with an Arduino or PICAXE LinkBox you can use this flowchart to control physical devices directly.
Note that there are two scripts running simultaneously. This is neccessary to ensure that if the safety switch is released the ride will stop immediately.