# Probability Spinner Project

Task: To create a probability spinner.

Difficulty: Beginner

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 motor;
• One push-to-make switch;
• Six croc-leads (or four is using motor with them pre-attached).

For the spinner you will also need:

• Card/paper;
• Pens/pencils;
• Scissors;
• Glue;
• Blu tack.

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 pack has been connected, we need to connect the motor. We do this by attaching the red(+) lead on the motor to the + motor pad on the Crumble, and the black(-) lead on the motor to the – Crumble motor pad. We can then attach the plastic wheel to the motor.

Finally, we need to attach a push-to-make switch. We need to connect one end of the switch to the + output on the Crumble, and the other end to I/O (A, B, C or D). As the default is A, we will connect to A.

Initially, we are going to look at how to get the motor turning. This is achieved by using the motor 1/2 block, then choosing a direction and a speed. In this example of code, the motor will turn for three seconds, and then stop.

To make the spinner random, we can use the random function to keep the motor spinning for a variable amount of time. In this example, the motor will spin for a random amount of time between 1 and 6 seconds.

At the moment, our spinner will only spin once, which isn’t of much use. We want to be able to spin it when we press the button. First of all, we are going to put the previous code inside a ‘do forever’ loop. Then we are going to add in a ‘wait until A is HI’ block, before we spin the motor. This means that each time the loop recurses, it will wait until the button is pressed.

So now we have a working probability spinner! However, to make this more true to life, we can adjust to motor speeds to make it appear to slow down.

Here we have set a variable called ‘speed’ to 100. After turning the motors for a random amount of time, we slow them down to a complete stop by repeatedly subtracting an amount between 1 and 10 from the motor speed until the speed is less than one.

hint: we use speed<1 as the speed value might not equal 0. If we didn’t, the value could become negative and the motor would begin speeding up in the other direction!

To make our spinner more useful, we need to add a pointer. We are going to make a small box to go over the top of the motor with a pointer attached to it.

Once we have printed off our template, we need to cut it out. When removing the circular section from the middle, take care not to cut the pointer off. We find it useful to carefully pierce the section to remove, and then cutting it out with scissors. You could also use a craft knife and cutting mat if you feel confident enough to do so.

Next we need to fold along the dotted lines, and glue the tabs together to form a ‘box’. If you wanted to add decorations to your spinner, then it is wise to do that before turning it into a box.

Finally, we need to add colours and/or numbers to a spinner face, and then attach this to our motor. We found a double-sided sticky pad useful, although blu tack would work just as well.

And there we have it! Our completed spinner, ready to play with.