For this project you will need:
- One Crumble with USB lead;
- A computer with the Crumble software installed;
- One battery pack with batteries (not rechargeable);
- One servo (and Crumbliser);
- One buzzer;
- One push-to-make switch;
- Nine croc-leads.
To make the clock you will need:
- Card and pens or Printed template;
- Two split-pins/paper fasteners.
First of all, we need to connect up the battery pack to the Crumble (keep it turned off for now). We need to take care with this as we must make sure that the + on the battery pack goes into the + input of the Crumble, and – on the battery pack connects to the – one on the Crumble.
After the battery is connected, we need to connect our other components. First we need to connect our Servo. We need to connect the + and – of it to the corresponding + and – on the battery pack, and the signal to an I/O (A, B, C or D) pad on the Crumble – We’ll use A for this.
Next we need to connect our push-to-make switch by connecting one end of the switch to the power output (+) on the Crumble, and the other end of the switch to an I/O (A, B, C or D). As A is already taken, we’ll use B.
Finally, we need to connect our buzzer. We decided to connect it to one of the motor outputs, with the intention of creating different noises. We connected the + and – of the buzzer to the corresponding + and – of the motor 1 output.
First of all, we are going to focus on getting our servo to ‘tick’ for 30 seconds.
A servo is surprisingly easy to use. You just have to ‘tell it’ which angle to turn to. They have a 180 degree range of motion, and we can use the servo block and a number between -90 and 90 to tell it where to turn.
The example block of code sets the servo to 90, then it waits one second before moving it 10 degrees. This continues until it has moved a total of 40 degrees.
We could continue this code so that it lasts for 30 seconds but there are two main issues. If we move move 10 degrees at a time, after 18 seconds we will have reached to the bottom of the clock face. Also, this code will be unnecessarily long, and not very efficient.
We need to travel 180 degrees around the clock face, in 30 seconds. 180/30 = 6, therefore we need to move 6 degrees per second (the angle at which a second hand on a clock moves).
To make this simpler and more efficient, we can use a ‘loop counter’ and a variable for the servo degrees. In this program, we set the variable to 90, then repeating 30 times, we set the servo to the variable, wait 1 second and decrease the variable by 6. This should give the illusion of a clock ticking.
Now we are going to use a switch to control our countdown clock. We want it so that if we push the button, the countdown starts and when this is finished, we push the button again to reset the timer.
In this code, we have used an ‘if _then’ block , so that when B is HI (button pressed), the countdown starts. When the countdown has finished, the program waits until the button is pressed again until it ‘resets’. The wait statement is used to prevent the button press from accidentally starting the countdown again.
The real Countdown clock has music to go alongside it, which helps to raise tension and alert ‘listeners’ to how long they have left. To replicate this, we are going to use a buzzer.
To get a buzzer to sound every second is quite simple, we just need to turn the buzzer on after the servo moves, then turn it off again after the wait statement. The issue with this is that the buzzer sounds for a whole second, and the pause is almost inaudible so the buzzer sounds continuously.
We want a nice ‘beep’ every second, so to do this, we need to break up our wait statement. We move the servo, and turn the buzzer on. We wait 100 milliseconds and then turn the buzzer off. Now we need to wait another 900 milliseconds (to make a total of 1 second) before subtracting 6 from our variable and repeating.
To extend the beeping further, and to make it more tense, we want the beeps to change so that when there is less time left, they beep more often. In this code, the beeping doubles in frequency after 17 seconds, then after 8 more. Finally, when the 30 seconds is up it lets out a long, high-pitched beep to signal the end.
Now that we have the inner workings of a clock timer, we need a clock to put it inside!
As we are using our template, the first thing we need to do is to print it out onto some card, and then cut out all of the pieces.
Next, we are going to attach our servo to the holder. We need to carefully put the split pins through the ‘holder’ and then bend them so that the servo is held in place.
Now we need to attach the servo and holder to the back of the clock face.
hint: to determine which way the servo needs to go, carefully twist it anti-clockwise until it stops – this should be the ‘top’
Then we need to fold along the dotted lines on the stand, and glue that to the bottom, rear-side of the clock face.
Finally, we need to reattach the hand to the servo and we’re finished!
Crocodile Leads (set of 12; length 240mm)£2.50 (£3.00 inc. VAT) Add to basket
Crumble Controller£10.00 (£12.00 inc. VAT) Add to basket
Crumble-friendly Push Switch£1.00 (£1.20 inc. VAT) Add to basket
Crumble-friendly Switched Battery Box£3.00 (£3.60 inc. VAT) Add to basket
Micro Servo (with Crumbliser)£5.00 (£6.00 inc. VAT) Add to basket