- A very cool and simple project which is extremely fun to operate. It has two types of instruments in it one being an 8-key piano and the other a 6-drum set .Hands-free all the way. Not too difficult to make but not too easy either.But don't worry this instruct-able will take you step by step on how to complete the aripinstrument . After completion you can develop tweaks in software , hardware or design and share or publish the new and improved design.
- Basic soldering
- Basic understanding of analog and digital data and data retrieval methods.
- A bit of python skills(not much actually as this instruct-able will show you how each line of code operates)
So, all the best on making this little instrument.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Materials Required
The Materials are not too costly and have good robust characteristics and a long life.
Here's your list:-
- A Raspberry pi 2 or above with Raspbian or NOOBS OS.(I used a pi 3 model B with built in WiFi)
- An SD card with 4 gigs or higher.(I used a 32 gig micro SD card)
- A micro USB cable with adapter.(or else You could also use a power bank if you want it to be mobile)
- All the peripherals namely mouse and keyboard.
- An ADS1115 analog to digital converter.
- A sharp IR distance sensor(GP2Y0A21YK0F is what I used)
- A basic breadboard.
- Jumper wires mainly male to female and male to male.
- A container to house the electronics.(optional)
- A small CPU fan for the RPI.(optional)
Step 2: Initial I2c Setup After Setting Up the RPI
Before we go on with the wiring first we need to enable the I2C bus.
What is an I2C bus?
Well basically its just a way or communication medium used by peripherals such as the ADC(Analog to Digital converter) uses here to talk with the computer(here RPI).
So to toggle the I2C bus on we can either enter in the terminal
else at the GUI interface we could go to the start button>> preferences>>Raspberry config and in advanced settings you can enable I2C .
After enabling I2C reboot the RPI.
Step 3: Connections
The connections are not at all tricky in this one.
- Place the ADC on the breadboard in a vertical fashion.
- Now connect the GND pin of the rpi to GND on the ADC and the GND in the sensor to the GND pin.(blue)
- Then the 3v pin to the VCC pin on ADC.(red)
- Then the SDA pin to the SDA pin to the ADC.(orange)
- The SCL pin to ADC SCL pin.(green)
- Then the signal pin from sensor to the A0 pin on ADC.(yellow)
That's it! You have successfully completed the connections part of it.
Step 4: The Coding
The coding for this project is really simple (i would suggest to make your own code suitable for you)
Here is the code though:
Firstly install pygame on your rpi to play the sounds:
<p>from time import sleep import pygame import Adafruit_ADS1x15</p><p>adc = Adafruit_ADS1x15.ADS1115(address=0x48, busnum=1)</p><p>GAIN=1</p><p>pygame.mixer.pre_init(44100, -16, 12, 512) pygame.init()</p><p>ton1 = pygame.mixer.Sound('Piano/c.wav') ton1.set_volume(1.00); ton2 = pygame.mixer.Sound('Piano/d.wav') ton2.set_volume(1.00); ton3 = pygame.mixer.Sound('Piano/e.wav') ton3.set_volume(1.00); ton4 = pygame.mixer.Sound('Piano/f.wav') ton4.set_volume(1.00); ton5 = pygame.mixer.Sound('Piano/g.wav') ton5.set_volume(1.00); ton6 = pygame.mixer.Sound('Piano/a.wav') ton6.set_volume(1.00); ton7 = pygame.mixer.Sound('Piano/b.wav') ton7.set_volume(1.00); ton8 = pygame.mixer.Sound('Piano/c2.wav') ton8.set_volume(1.00); ton9 = pygame.mixer.Sound('Piano/beep.wav') ton9.set_volume(1.00); dton1 = pygame.mixer.Sound('Piano/open.wav') dton1.set_volume(.65); dton2 = pygame.mixer.Sound('Piano/kick.wav') dton2.set_volume(.65); dton3 = pygame.mixer.Sound('Piano/cymbal.wav') dton3.set_volume(.65); dton4 = pygame.mixer.Sound('Piano/snare.wav') dton4.set_volume(.65); dton5 = pygame.mixer.Sound('Piano/closed.wav') dton5.set_volume(.65); while 1: while 1: value =  value = adc.read_adc(0, gain=GAIN) val=value/32767.0 * 6.144 if val < 4.7 and val > 3.7: ton1.play() if val < 3.7 and val > 3.0: ton2.play() if val < 3.0 and val > 2.6: ton3.play() if val < 2.6 and val > 2.15: ton4.play() if val < 2.15 and val > 2.00: ton5.play() if val < 2.00 and val > 1.77: ton6.play() if val < 1.77 and val > 1.45: ton7.play() if val < 1.45 and val > 1.36: ton8.play() if val < 1.2 and val > 0.99 : ton9.play() sleep(2) break; sleep(0.1) while 1:</p><p> value =  value = adc.read_adc(0, gain=GAIN) val=value/32767.0 * 6.144 if val < 4.7 and val > 3.7: dton1.play() if val < 3.7 and val > 3.0: dton2.play() if val < 3.0 and val > 2.6: dton3.play() if val < 2.6 and val > 2.15: dton4.play() if val < 2.15 and val > 2.00: dton5.play() if val < 1.2 and val > 0.99 : ton9.play() sleep(2) break; if val < 0.9 and val > 0.8: exit 0 sleep(0.1)</p>
Step 5: Finally the Body!
Well I used a Hershey's cocoa powder box but you can use something much more sleek and elegant.
- I cut a perfect rectangular hole for the sensor
- then,Cut two other holes
- one for the power to the RPI and
- the other for the audio output jack.
- Finally i cut a few holes to ventilate the RPI.
Step 6: All the Best!!
Congrats you built your own Airpinstrument!!
If you have any code updates or amazing designs for the body or amazing ideas using this instrument please feel free to share.
Participated in the
Microcontroller Contest 2017