Introduction: Raspberry Pi Infrared Keyboard
I've always loved music, so when thinking about what I would make as my first Raspberry Pi project, my mind naturally went to it. But ofcourse I wanted to give it an extra touch, or better, no touch! With the current Covid-19 crisis and all the hygene and touching ristrictions in mind, I choose to make a keyboard where the keys were repalce by infrared sensors. You can change the key you are playing in by turning a rotary encoder and pressing it will trigger a backingtrack to start, of wich the tempo can be changed by tapping a touchsensor.
I have given the look a xylophone-piano vibe, wich I have also integrated on the website, where you can see what notes are being played. To build the case, I've only used wood,wich I painted to give it the finishing touch.
Step 1: Part List
- Raspberry Pi 4 Model B v1.2 - 2GB
- Assembled Pi T-Cobbler Plus
- 40pcs 10cm Male To Female Jumper
- Cable 40pcs 10cm Male To Male Jumper Cable
- IR Obstacle avoider
- Different pieces of wood
- Touch sensor
- Raspberry pi 4
- adapter resistor package
- Rotary encoder
Price: around 230 euros but depends on case
Step 2: Electronics
Wire your electronics like in the given pdf. Be aware that the Infrared Sensor might need some readjusting to make sure they don't send signals at times they are not triggered.
My speaker is plugged into an external usb sound card to inprove sound, but you can also just plug it into the pi's jack output.
Step 3: Database
This is the database I created. I used a table containing all notenames and coresponding midi note values. Another table contains the keys wich you can choose between. The table PlaySession contains all previously saved tracks you played and connected to that are the notes in this track.
Step 4: Assembeling Electronics
Next came the assembly of the electronics. I decide to leave everything on a breadboard and not to solder it, because I am not that good at solderen and the IR sensors are quite sensitive so it could happen you will have to replace one someday.
Step 5: Coding
For coding I used a python Library call Mingus wich uses FluidSynth to play midi notes.
To set up both you'll need to run the following commands:
pip install mingus
pip install fluidsynth
You can find the code on my GIT.
Step 6: Website
Next, designed and coded my website. I used html, css and JS with websockets to communicate with the server running in the back.
Step 7: Building Case
I designed my case to resemble a kind of xylophone/ Piano. I made everything in wood and decided to give everything a lick of paint to make it look even nicer.
Step 8: And Now.. Play!
Now you are ready to start playing your selfmade instrument! Don't be afraid to ask any questions in the comments and have fun creating!
Participated in the
First Time Author Contest