Integers can be tricky! But why not make a fun game and let a micro-controller help you add and subtract?
- egg cartons/cup holders (you can get them from Cafes)
- 4 Plastic cups
- Jumper wires (generic)
- Aluminium foil
- flexible thin conducting wire
Calliope has 4 output pins (0,1,2 and 3) and a GND pin (-). The four cups are connected to the four different pins and the a ball (made of aluminium foil) is connected to the GND pin using a long thin flexible conducting wire.
Every time the ball is thrown in the cup, the circuit is completed to perform the desired actions. A schematic diagram is shown below:
4 cups are positioned one behind the other in cup holder and CalliopeMini is attached in the front (using double sided tape) to display the score.
Firstly, with the metal pins insert it into the base of each cup (pointed tip inside the cup). Using wires connect each cup to the Calliope pins.
Make sure the contacts are not loose and the wires do not touch each other. Crumple some foil to make a ball and use long conducting metal wire to connect it to the GND pin.
Your hardware is ready!
The code was written in http://pxt.calliope.cc/
The program is such that the nearest cup increases the point by 2, farthest by 5. the second cup adds 1 to the score but the third cup subtracts 3. Screenshot of the code is below:
** A short clip of the demo of this project can be seen here: