Skip to main content

Arduino Starter Kit - Video 5. Keyboard Instrument

This tutorial builds on the previous video [Light Theremin], where Massimo Banzi showed how to build a light-controlled theremin out of an Arduino. In this video tutorial Massimo shows how to build a simple musical instrument controlled by buttons, rather than a sensor. This project introduces the concept of a "resistor ladder" and how it can be used to modulate an input signal from the buttons to the Arduino.

This circuit has four buttons connected to a piezo speaker, so that every time a button is pressed a different sound is played by the piezo capsule.

While in previous examples every button was wired to different digital pins on the Arduino, in this case a single wire runs through the buttons, connecting them to an analog pin. Buttons are connected to the wire using different resistors, therefore changing the voltage that is transfered to the Arduino according to which button has been pressed. This configuration is know as a "resistor ladder", a simple and inexpensive way of building a digital-to-analog mapping, as each different combination of buttons produces a different voltage.

The voltage generated by the buttons is then controlled by the code running on the Arduino. As we saw in the case of the theremin, the value is then sifted through a sequence of if-statements to determine which buttons have been pressed. An array is then used to map the C, D, E and F notes to the different vibration sequences of the piezo buzzer, played using the tone() function.

This tutorial teaches how to combine different input sources into a single analog signal and how to unpack them back via code. You can check out previous videos [RS Arduino Youtube Channel] and subscribe to more Arduino video tutorials [Click Here]

DesignSpark Electrical Logolinkedin