Designed by
Jiamin Zeng(jz863), Zhenyan Zhang(zz488)
In our final project, what we implemented is a gesture-controlled piano. As the real piano, the gesture-controlled piano also contains seven keys, each representing the key sound “Do”, “Re”, “Mi”, “Fa”, “So”, “La”, “Si”. However, we want our piano to make a sound without directly being contacted. To achieve this purpose, motion sensors will definitely be implemented in our design to replace the tangible keys or buttons.
We finally choose the IR Break Beam Sensor. This sensor contains one emitter and one receiver. We put the emitter and the receiver at the opposite position of each other, face to face. In this way, the receiver can receive the infrared beam the emitter generated. Moreover, the receiver is connected to the GPIO pins of the Raspberry Pi. In normal state, the receiver can receive the beam and generates no signal to the GPIO pin. However, once we put our fingers between the emitter and the receiver to cut through the beam path, the receiver will generate a falling down signal to the GPIO pin which can be detected by the callback in our program.
We recorded the key sound “Do”, “Re”, “Mi”, “Fa”, “So”, “La”, “Si” in .wav file and once the callback detects the falling edge of one certain key, the program will play the sound by the music load function of pygame. We connect one speaker to the raspberry pi and then the key sound can be played to public.
We also design some graphics animation on our screen. We show a picture of a piano keyboard on the RPi screen and once a key sensor is detected, the corresponding key name will be shown on the RPi screen at the position of the corresponding key.
We set a quit button in our design so we can quit this program whenever we want. We made some modifications to the rc.local file and then the program of our design can start automatically when the raspberry is powered on.
Previous Version 1
At first, we use many “if” statement and PIR motion detection function in our code to implement what we want. However, later we found this is not a good way of implementation because we use time.sleep() in our code to control the time of some operation which causes low sensitivity of detecting the movement beyond one key. So, later we use callback to implement our design and in this way the movement can be detected timely.
We originally chose the PIR motion sensor in our design. However, this kind of sensors have some drawbacks. First, the detecting range of it is very large while we just need our piano key sensor to detect a small range of movement of our fingers. Though we can adjust its detection range by adjusting the knob on it, the minimum detection range is still beyond what we need. Second, this kind of sensor has a fixed-time pulse time (blocking time) of 2.5 seconds which means once it detects a movement, it generates a high-level voltage and this voltage will go down after exact 2.5 seconds.
This fixed-time pulse time means a limit that we can’t press one key consecutively two times in 2.5 seconds otherwise the second press won’t be detected because the callback in our program needs the rising edge from GPIO pin to detect a movement. To solve this problem, later we change our sensor to IR Break Beam Sensor.
Previous Version 2
When we first set the IR Break Beam Sensor in our design, we put the emitter and the receiver in horizontal positions, one next to each other. And we think there will be some intersection space in the air beyond the emitter and receiver and as our expectation the devices do work well in this position. However, later we found that our devices can’t work if we turn off the lights around which means the way we set the emitter and the receiver is wrong that the receiver can’t receive the beam from the emitter next to itself. It works well just because the receiver can receive the infrared light generated by the lab bulbs. So later, we put them in the opposite way, face to face.