Coin Eater

Build your own electronic cash register that detects when a coin is inserted and plays a sound signal! Learn the basics of programming, electronics, and working with sensors in a fun way - ideal for teaching physics, mathematics, or for home discovery and creation.

Description

The money box is a clever project that turns an ordinary money box into a fun device for systematic savings. It uses a sensor to detect when a coin is inserted and automatically registers it - it can play a sound, light up an LED, display an animation or count the coins. Thanks to the micro:bit and an expansion board, you can easily customize it with your own ideas and functions, for example by connecting a display or a motor.

This kit is ideal for school and home projects and does not require any advanced knowledge. Children and adults will practice programming, basic sensory skills and logical thinking while working with it. The money box can be programmed in MakeCode or Python, making it suitable for both complete beginners and more advanced tinkerers.

Connection

Expansion board MB2

The cash register has one IR sensor that is connected with 3 Dupont wires and a button that is connected with 2 wires.

There are 4 pins on the IR sensor – VCC (power), GND (ground), D0 (Digital signal) and A0 (Analog signal). The IR sensor is connected to the expansion board as follows. We connect all the duponts to pin 2 so that the signal pin DO to the yellow signal bar, VCC to the white power bar and GND to the black ground bar.

There are 3 pins on the button – C, N0 and NC. We connect the button to pins C and N0. We connect pin C to the expansion board on P1 to the yellow signal bar, we connect pin N0 to the black ground bar.

And finally, we connect the servo motor to pin 0 so that the yellow dupont is connected to the yellow strip.

coineater_MB2

Recommendation

When you first start the cash register, you need to set the sensitivity of the IR sensor. Start by inserting a Phillips screwdriver into the blue square on the sensor. By turning the screwdriver, you are able to set the switch point. This allows you to determine when you want the sensor to turn on.

Program

The insatiable piggy bank

This code works so that the cash register responds to coin detection.

First, we set pins P1 and P2 so that they are ready for detection. The principle of the whole program is that the micro:bit constantly waits until the signal is interrupted. The signal is interrupted by feeding the money box with a coin. Pin P2 then issues a signal that starts the servo motor. It turns to a value of 180 and opens the money box using its arms. It waits in this position for 500 ms. Then the servo turns to a value of 90. The last step is that the program waits 1 second for the whole process to finish. Then the money box waits for the next coin. But be careful, the money box is very greedy!

Tasks

Task 1: Revive a money box with two wires and aluminum tape

Instead of the IR sensor, use two wires that you place on the paddle inside the cash register. Cover the wires with aluminum tape so that they create an electrical circuit when they come into contact with a metal coin. Observe whether this way the cash register better recognizes the coin being inserted.

Task 2: Reaction according to the value of the coin

Create a program that distinguishes different types of coins by the time they hit (lighter coins hit earlier, heavier coins hit later) or by the number of contacts. Each type of coin can trigger a different animation, sound, or action. For example, try having a five-krona coin activate a motor and a ten-krona coin light up an LED strip.

Task 3: Power saving mode

Schedule your money box to sleep. If no coin is inserted for a certain period of time (for example, 30 seconds), the display will turn off or a sleep animation will appear. When a coin is inserted, the money box will wake up and display the current savings status.

Gallery