I am a big fan of TwoSetViolin, they bring me a lot of fun and I start to appreciate the joy of music since I followed their channel last year. They have a program called LINGLING40HOURS, in which there are many linglings (talented fans) showing their music memes. Well, I know nothing about instruments, so it’s hard for me to come up with any good music memes. Okay, at last, I decided to utilize my expertise to DIY an electronic organ to join them.
Hardware
Raspberry Pi IO Expansion Board X1
Capacitive Touch Kit For Arduino X1
Gravity: Digital Speaker Module X1
Ice Cream Sticks (3*7)
Double Side Adhesive
Copper Foil Tape with Double-Sided Conductive
Conductor WireCardboard
Type-C power cable
Ethernet Cable X1 (Can be replaced by WiFi)
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/4469874dc2a80ed60eb6427151e141ab.jpg)
Electronic Organ Key Connection
1. First, we have to figure out the logic before soldering: MPR121 can output 12 signals, but we need 3*7=21 signals. So here I am gonna divide the 12 signals into two groups: X (0-4), Y(5-11), then we can get 35 signal combinations.
Solder conductor wires onto the touch board(21 in total). I soldered the green and yellow points.
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/4d099a06e03cdab949002bb555a6741d.png)
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/292acda6f1db776f111ca1e7daa0a89a.jpg)
2. Prepare the organ plate
Cut cardboard of three layers and prepare some small cardboard strips for fix the organ keys.
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/94a0530aebe8c488a4a7ef4c01d477fa.jpg)
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/3e52ed996d2969ede4ebde71568e22fb.jpg)
Stick the touch board onto the middle layer of the cardboard. And drill holes on the boards, then pull out the conductor wires.
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/a76bd513785ea28c0253b2917ec13dc4.jpg)
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/482af2f0d5d92bacea2105c514aa5e9d.jpg)
Organize the wires and cut out the extra parts.
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/095f6495da615441e28e1dc25726c897.jpg)
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/f772bf180b4ca5d5bbdd07c5486d8d0c.jpg)
3. Prepare the organ keys
Wrap the copper tapes around the ice cream sticks.
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/fc47d10ffc0995f8a972da2fa6aacedc.jpg)
Stick them onto the cardboard.
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/2b5a82a89646ed48cddfecb031b7c9a8.jpg)
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/b2e802644b3186b00eba206902db1731.jpg)
Software Preparation
I used the MobaXterm here.
Operation
1. Hardware Connection
Connect the speaker module to P22 of the expansion board, the touch board to IIC port.
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/6bd03700f6161d35108a47f385b6eed5.png)
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/4e5f4755dc49781e3e5f70d398aa9cf3.jpg)
You can also select other pins, but please make sure it is a GPIO port.
At last, plug in the power cable and Ethernet cable.
2. Programming
1) Download libraries files. I have placed them into a zip, click the link to download them to your PC.
The unzipped files should be like that in the image below.![projectImage](https://dfimg.dfrobot.com/nobody/makelog/f242bd1934b576812fd43c0887dee4f3.png)
Drag the files to mobaxterm. (Please select Desktop path)
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/baddb148efc44fe49968b442da21b9b1.gif)
Create a python file in your computer and name it as 36.py.
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/cec50283307aa81fafa8875dbc413b4d.png)
Once a button is pressed, the speaker will play the corresponding note. The touch function in MPR121 library can only output 0~11, and we have to extend the 12 signals. So here I take 0~4 as X, 5~11 as Y, so there will be 5*7=35 combinations. I only set the G clef (treble clef), the F clef (bass clef), the C clef (alto clef). When x=1, bass clef, the frequency will be determined by the value of Y. When x=2, alto clef, the frequency will be determined by the value of Y, and so on.
Copy the following codes into 36.py file.
import sys
sys.path.append('../')
import time
import Adafruit_MPR121.MPR121 as MPR121
import RPi.GPIO as GPIO
Buzzer = 22
GPIO.setmode(GPIO.BCM)
GPIO.setup(Buzzer,GPIO.OUT)
Buzz = GPIO.PWM(Buzzer,440)
Buzz.start(0)
print('Adafruit MPR121 Capacitive Touch Sensor Test')
# Create MPR121 instance.
cap = MPR121.MPR121()
CL = [131, 147, 165, 175, 196, 211, 248]
CM = [262, 294, 330, 350, 393, 441, 495]
CH = [523, 587, 659, 698, 784, 880, 988]
if not cap.begin():
print('Error initializing MPR121. Check your wiring!')
sys.exit(1)
print('Press Ctrl-C to quit.')
last_touched = cap.touched()
print(last_touched)
x = 0
y = 0
while True:
global Buzz
touch = []
current_touched = cap.touched()
n=current_touched
print(n)
#y=current_touched[1]
for i in range(12):
if n&1:
touch.append(i)
n = n >> 1
if len(touch) == 2:
x=touch[0]
y=touch[1]-5
print(x)
print(y)
if x==1:
Buzz.start(50)
Buzz.ChangeFrequency(CL[y])
elif x==2:
Buzz.start(50)
Buzz.ChangeFrequency(CM[y])
elif x==3:
Buzz.start(50)
Buzz.ChangeFrequency(CH[y])
else:
Buzz.stop()
x = 0
y = 0
#last_touched = current_touched
time.sleep(0.5)
#GPIO.cleanup()
Drag the 36.py file into the examples of mobaxterm.
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/278a66f887ec589f0d07c8d0e49f06a7.png)
Effect Display
As shown below, I pressed the sixth note of the bass clef. That's all for my work, thanks for reading!
![projectImage](https://dfimg.dfrobot.com/nobody/makelog/c97b63e4ea4188577b5ede448e55d16a.png)
![licensBg](/images/license_bg.png)