Introduction: Hacking a Ball Circuit Toy With Raspberry Pi
The concept is to hack a ball circuit with raspberry Pi 2 Kano computer and add a sensor and lights for more fun.
The ball circuit is a Solar powered Circuit from Miniland. The idea is to remove the solar power and power the circuit from the Raspberry Pi. We switch on the circuit with the IR sensor and we also add lights to signal on/off state of the motor (red led) and the motion of the balls (oscillating yellow lights). In the screen, we see the state of the machine and a counter with the number of loops for the oscillating lights.
The program to control all the system is written in python 2.
Design, build up and program by Jofre Faraudo (after reciving a Kano and the solar circuit as Christmas gifts). Photos taken by Jofre Faraudo. Video by Jordi Faraudo. Instructions written by Jordi and Jofre Faraudo.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Connect the Ball Circuit to Breadboard
The motor of the circuit has a plug for the solar panel. Remove the solar panel and add two female to male jumpers going from the motor plug (female) to a breadboard (male). Connect one of the jumpers to + and the other one to - in the breadboard (polarity of the motor does not matter, balls always will be going upstairs!!).
Step 2: Add the Leds
We add a red led and two yellow led to the breadboard (if this is your first time connecting leds see here for an introduction on how to flash a led to Kano). First we connect a red led to a column of the breadboard (we used column G). The + side of the red led was connected with a short cable to the + column of the breadboard (not the + used for the motor of the circuit, we used the other side of the breadboard). The - side of the red led was connected to a 220 Ohm resistor. The resistor was connected to the - side of the breadboard.
Now add two yellow led to the breadboard in two different columns (we used F and H). Add two cables, connecting the - side of each yellow led to the - side of the red led (and they will be also connected to the aforementioned resistor) . Connect the + side of each yellow led to a male-to-female jumper. These jumpers will go to the GPIO of Kano Raspberry Pi.
We finally add a cable to connect the two - columns in the breadboard. The motor and the three led will share the same GND.
Step 3: Prepare the IR Sensor
We will use a IR sensor to switch on the motor, embedded into a Lego support to make easier its use with a finger for example. The instructions for the lego support are given here in Lego Digital Designer format. As IR sensor we use the inexpensive TCRT5000 IR sensor (see here for a discussion forum on how to use it).
First we make the Lego support. Then we add jumpers to the IR sensor. The sensor has three "male" pins and in our model they are labelled as GND,Vcc,Out. The GND will be connected to a GND of Raspberry Pi Kano , so we add a jumper. The Vcc is the power supply, we connect it to a 220 Ohm resistor with a jumper and we add another jumper to the other end of the resistor to be able to connect it to a 5V power supply from GPIO of Raspberry Pi. The Out pin is the output and will be connected to another GPIO, so add a jumper to it.
Step 4: Connecting to Raspberry Pi
Now it is time to connect the GPIO to the breadboard and IR sensor using the jumpers, as shown in the scheme.
If you are using a KANO Raspberry Pi you have to disconnect first the KANO speaker, because the speaker connector blocks some of the pins in spite of not using them (a message to KANO designers: could you design the speaker not to block the first two pins which are not used by the speaker?).
The scheme shows the connections , which are not listed for convenience:
Ground: As shown in the scheme we use two GPIO GNDs, one connected to the breadboard and the other one to the IR sensor GND.
GPIO 26 is connected to the + side of one of the yellow leds at the breadboard. The GPIO 21 is connected to the + of the other yellow led.
GPIO 14 provides power to the red led, it is connected to one of the + sides of breadboard.
GPIO 4 provides the power to the motor and has to be connected to the + side of the breadboard corresponding to the motor.
GPIO 20 is used to receive output from the sensor, and it is connected to the Out pin of the IR sensor.
5V output (the one located over the GPIO number 2) is used as power for the IR sensor, it is connected to the resistor attached to the IR sensor as described in the previous step.
Step 5: Python Program
The python program can be obtained from GitHub ( download here ).
First, the program waits for a signal (1) from the IR sensor. A sheet of paper or a finger close to the sensor gives a current and hence a 1 signal from the input GPIO. Once the sensor is activated, the red light flashes and a message appears at the screen. After these initial flashes, the red led is on and the motor starts to run, pulling the balls up. Also, the yellow lights oscillate following the motion of the balls. At the screen, the program shows the number of loops of the light oscillations. After some loops, the program stops automatically (this end can be easily modified to wait again for the IR sensor).
Participated in the
Raspberry Pi Contest 2016