// https://wokwi.com/projects/426319240866310145
void setup() {
Serial.begin(115200);
Serial.println("\nWake Up!\n");
noteOn(42, "test", 0);
noteOff(777, "also test", 0);
}
void loop() {
delay(433);
wtf();
}
int SLIDE1;
int SLIDE1_OLD = -1;
int lastNote = -1;
# define TRANS_KEY 10
void wtf()
{
int theReading = analogRead(A0);
// Serial.print(theReading); Serial.print(" <A0 ");
int SLIDE1 = map(theReading, 50, 975, 1, 14);
if (analogRead(0) < 50) {
SLIDE1 = 0;
}
if (analogRead(0) > 975) {
SLIDE1 = 15;
}
if (SLIDE1 != SLIDE1_OLD) {
Serial.print("SLIDE1> "); Serial.print(SLIDE1);
Serial.println("");
if ((SLIDE1 > 0) && (SLIDE1 < 15)) {
noteOff(lastNote, " 1..14 ", 1);
noteOn((SLIDE1 + 59 + TRANS_KEY), " 1..14 ", 1);
lastNote = SLIDE1 + 59 + TRANS_KEY;
}
if (SLIDE1 == 0) {
noteOff(lastNote, " ZERO ", 1);
}
if (SLIDE1 == 15) {
noteOff(lastNote, " FIFTEEN ", 1);
}
SLD_SCN (SLIDE1);
SLIDE1_OLD = SLIDE1;
}
}
void noteOn(int aNote, char *msg, int)
{
Serial.print(" note on : "); Serial.print(msg); Serial.println(aNote);
}
void noteOff(int aNote, char *msg, int)
{
Serial.print(" note off : "); Serial.print(msg); Serial.println(aNote);
}
void SLD_SCN(int wtf)
{
Serial.print(" SLD_SCN : "); Serial.println(wtf);
}
/*
if (SLIDE1 != SLIDE1_OLD) {
if ((SLIDE1 > 0) && (SLIDE1 < 15)) {
noteOff(Last_Note, 0, 1);
noteOn((SLIDE1 + 59 + TRANS_KEY), 127, 1);
Last_Note = SLIDE1 + 59 + TRANS_KEY;
}
if (SLIDE1 == 0) {
noteOff(Last_Note, 0, 1);
}
if (SLIDE1 == 15) {
noteOff(Last_Note, 0, 1);
}
SLD_SCN (SLIDE1);
SLIDE1_OLD = SLIDE1;
}
}
*/