//example project:
//https://create.arduino.cc/example/builtin/02.Digital%5CtoneKeyboard/toneKeyboard/preview
// this project is not ready, because the resources is not enough.
// missing resources:
// 3 force sensing resistors
// 3 10k ohm resistors
// replacement:
// 100 ohm resistor : 100 resistor
// 8 ohm speaker : wokwi-buzzer
// Arduino Board: wokwi-breadboard
#include "pitches.h"
//minimum reading of the sensors that generates a note
const int threshold = 10;
// notes to play, corresponding to the 3 sensors:
int notes[] = {
NOTE_A4,
NOTE_B4,
NOTE_C3
};
// put your setup code here, to run once:
void setup() {
}
// put your main code here, to run repeatedly:
void loop() {
for (int thisSensor = 0; thisSensor < 3; thisSensor++) {
// get a sensor reading:
int sensorReading = analogRead(thisSensor);
// if the sensor is pressed hard enough:
if (sensorReading > threshold) {
// play the note corresponding to this sensor:
tone(8, notes[thisSensor], 20);
}
}
}