Soft Sensing: Music Instrument

For the last assignment of Soft Sensing class, I decided to continue my Soft Piano, but instead of using a piano melody, I used random sounds instead (e.g. clap, bass, fireworks, bell, etc.) to make the sound more interesting.

Materials

  • Conductive tape
  • Foam sheet
  • Tape
  • Wire

Components

  • Arduino MKR1000 (or UNO)
  • Resistor 1M Ohm

 

Wiring

I used conductive tapes as switches. So you can replace the switches with conductive tapes.

Music Instrument Wiring

Code


#include "Keyboard.h"

// set pin numbers for the five buttons:
const int keyAInput = 1;
int valueA = 0;
const int keySInput = 2;
int valueS = 0;
const int keyDInput = 3;
int valueD = 0;
const int keyFInput = 4;
int valueF = 0;
const int keyGInput = 5;
int valueG = 0;
const int keyQInput = 6;
int valueQ = 0;
const int keyWInput = 7;
int valueW = 0;
const int keyEInput = 8;
int valueE = 0;
const int keyRInput = 9;
int valueR = 0;
const int keyTInput = 10;
int valueT = 0;

void setup() { // initialize the buttons' inputs:
pinMode(keyAInput, INPUT);
pinMode(keySInput, INPUT);
pinMode(keyDInput, INPUT);
pinMode(keyFInput, INPUT);
pinMode(keyGInput, INPUT);
pinMode(keyQInput, INPUT);
pinMode(keyWInput, INPUT);
pinMode(keyEInput, INPUT);
pinMode(keyRInput, INPUT);
pinMode(keyTInput, INPUT);

Serial.begin(9600);
Keyboard.begin();
}

void loop() {

valueA = digitalRead(keyAInput);
valueS = digitalRead(keySInput);
valueD = digitalRead(keyDInput);
valueF = digitalRead(keyFInput);
valueG = digitalRead(keyGInput);
valueQ = digitalRead(keyQInput);
valueW = digitalRead(keyWInput);
valueE = digitalRead(keyEInput);
valueR = digitalRead(keyRInput);
valueT = digitalRead(keyTInput);
if (valueA == HIGH) {
Keyboard.write('a');
} else if (valueS == HIGH) {
Keyboard.write('s');
} else if (valueD == HIGH) {
Keyboard.write('d');
} else if (valueF == HIGH) {
Keyboard.write('f');
} else if (valueG == HIGH) {
Keyboard.write('g');
} else if (valueQ == HIGH) {
Keyboard.write('q');
} else if (valueW == HIGH) {
Keyboard.write('w');
} else if (valueE == HIGH) {
Keyboard.write('e');
} else if (valueR == HIGH) {
Keyboard.write('r');
} else if (valueT == HIGH) {
Keyboard.write('t');
}
delay(10);
Serial.println(valueA);
}

The way it works is the switches (conductive tapes) will type in a letter on keyboard. I assigned each switch to a letter in the keyboard. And when a keyboard is pressed, a sound will be produced. To play with it, I created a web page to play the sounds using keyboard here: Vidia’s Patatap.

Final Product

Final Product

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *