September 20th, 2015
https://youtube.com/watch?v=sSkXQL6ItJ0
You will need the following:
As many 10k Resistors as you want inputs/keys
As many BC548B transistors as you want inputs
1x Arduino mega
A breadboard
And some jumper cables.
Place your transistor so that the emitter(3) is connected to ground, and the collector(1)/base(2) are 1 or more pins apart.
Place the 10k resistor so that is hits +5v and the collector(1)
Connect positive to +5v on the breadboard and Arduino, and negative to GND(ground).
Connect a jumper from A0(Analog Input 0) to the Collector pin.
Connect a jumper to the unused(Base(2)) pin, this will connect to whatever you want to play such as an apple or banana.
Connect a speaker/buzzer to pin 3 and GND and it should look like this.
Upload the following code:
DOWNLOAD:
tonekeyboarduno.zip(Uno), tonekeyboardmega.zip(Mega)
(Mega)
/*
Capacitive Tone keyboard
Plays a square-wave at a given frequency when triggered.
circuit:
* 10k resistor from +5V to the collector of each BC548B
* Speaker on Digital Pin 3
created 20 September 2015
by Joey Babcock ( http://joeybabcock.me )
**Note this is for arduino mega only./
#include “pitches.h”
// notes to play, corresponding to the 3 sensors:
int notes[] = {
NOTE_C3, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_G3, NOTE_A3, NOTE_B3, NOTE_C4
};
void setup() {
Serial.begin(9600);
}
void loop() {
for (int curSensor = 54; curSensor < 61; curSensor++) {
// get a sensor reading, pin 54 is equivelent to A0
int sensorReading = analogRead(curSensor);
Serial.print(sensorReading);
Serial.print(” “);
// if the transistor has made contact
if (sensorReading < 500) {
// play the note corresponding to this transistor:
tone(3, notes[curSensor-54], 50);
}
}
Serial.println+(” “);
}
(Uno)
/* Capacitive Tone keyboard Plays a square-wave at a given frequency when triggered. circuit: * 10k resistor from +5V to collector of each BC548B * Speaker on Digital Pin 3 created 20 September 2015 by Joey Babcock ( http://joeybabcock.me ) **Note this is for arduino mega only./ */ #include "pitches.h" // notes to play, corresponding to the 3 sensors: int notes[] = { NOTE_C3, NOTE_D3, NOTE_E3, NOTE_F3, NOTE_G3, NOTE_A3, NOTE_B3, NOTE_C4 }; void setup() { Serial.begin(9600); } void loop() { for (int thisSensor = 14; thisSensor < 18; thisSensor++) { // get a sensor reading: int sensorReading = analogRead(thisSensor); Serial.print(sensorReading); Serial.print(" "); // if the sensor is pressed hard enough: if (sensorReading < 500) { // play the note corresponding to this sensor: tone(3, notes[thisSensor-14], 50); } } Serial.println+(" "); }