I've created a MIDI "Air Harp" instrument. Some prototype info:
Video: https://youtu.be/VMS8y9XyK0A
Images: https://imgur.com/5UsVyRW
https://imgur.com/H30AUpI
https://imgur.com/b1ulnFd
https://imgur.com/zaTGVYp
The current code:
I'll try to make the code more elegant at some point.
Next step that I need help on:
I'm replacing the sticks in the prototype with clear tubes. Then I'm putting 3-9W LEDs at the bottom of the tubes. The idea is that the tubes will be one color when idle and another when activated.
Here's a CAD image:
I've bought this LED controller from adafruit:
https://www.adafruit.com/product/1429
As I understand it, I need to include the TLC5947 library in my above code. I think I can figure out the setup code. I'm not positive how to use the loop code. Here's a template of what each note/tube code would look like:
I'm sure it's simple, but I'm not understanding what to use based on Adafruit's sample code.
Thanks much for any help!
Video: https://youtu.be/VMS8y9XyK0A
Images: https://imgur.com/5UsVyRW
https://imgur.com/H30AUpI
https://imgur.com/b1ulnFd
https://imgur.com/zaTGVYp
The current code:
Code:
int noteIsOn1;
int noteIsOn2;
int noteIsOn3;
int noteIsOn4;
int noteIsOn5;
int noteIsOn6;
int noteIsOn7;
int noteIsOn8;
int thresh;
int vel;
void setup() {
thresh = 400;
//thresh = constrain(thresh, 230, 232);
vel = (random(90,120));
}
void loop() {
/// Sensor 1
if (noteIsOn1 == false) {
if (analogRead(0) > thresh) {
usbMIDI.sendNoteOn(60, random(90,120), 1);
noteIsOn1 = true;
}
} else {
if (analogRead(0) < thresh) {
usbMIDI.sendNoteOff (60, 0, 1);
noteIsOn1 = false;
}
}
/// Sensor 2
if (noteIsOn2 == false) {
if (analogRead(1) > thresh) {
usbMIDI.sendNoteOn(62, random(90,120), 1);
noteIsOn2 = true;
}
} else {
if (analogRead(1) < thresh) {
usbMIDI.sendNoteOff (62, 0, 1);
noteIsOn2 = false;
}
}
/// Sensor 3
if (noteIsOn3 == false) {
if (analogRead(2) > thresh) {
usbMIDI.sendNoteOn(64, random(90,120), 1);
noteIsOn3 = true;
}
} else {
if (analogRead(2) < thresh) {
usbMIDI.sendNoteOff (64, 0, 1);
noteIsOn3 = false;
}
}
/// Sensor 4
if (noteIsOn4 == false) {
if (analogRead(3) > thresh) {
usbMIDI.sendNoteOn(65, random(90,120), 1);
noteIsOn4 = true;
}
} else {
if (analogRead(3) < thresh) {
usbMIDI.sendNoteOff (65, 0, 1);
noteIsOn4 = false;
}
}
/// Sensor 5
if (noteIsOn5 == false) {
if (analogRead(4) > thresh) {
usbMIDI.sendNoteOn(67, random(90,120), 1);
noteIsOn5 = true;
}
} else {
if (analogRead(4) < thresh) {
usbMIDI.sendNoteOff (67, 0, 1);
noteIsOn5 = false;
}
}
/// End Sensor
/// Sensor 6
if (noteIsOn6 == false) {
if (analogRead(5) > thresh) {
usbMIDI.sendNoteOn(69, random(90,120), 1);
noteIsOn6 = true;
}
} else {
if (analogRead(5) < thresh) {
usbMIDI.sendNoteOff (69, 0, 1);
noteIsOn6 = false;
}
}
/// End Sensor
/// Sensor 7
if (noteIsOn7 == false) {
if (analogRead(6) > thresh) {
usbMIDI.sendNoteOn(70, random(90,120), 1);
noteIsOn7 = true;
}
} else {
if (analogRead(6) < thresh) {
usbMIDI.sendNoteOff (70, 0, 1);
noteIsOn7 = false;
}
}
/// End Sensor
/// Sensor 8
if (noteIsOn8 == false) {
if (analogRead(7) > thresh) {
usbMIDI.sendNoteOn(72, random(90,120), 1);
noteIsOn8 = true;
}
} else {
if (analogRead(7) < thresh) {
usbMIDI.sendNoteOff (72, 0, 1);
noteIsOn8 = false;
}
}
/// End Sensor
while (usbMIDI.read()) {}
delay(5);
}
I'll try to make the code more elegant at some point.
Next step that I need help on:
I'm replacing the sticks in the prototype with clear tubes. Then I'm putting 3-9W LEDs at the bottom of the tubes. The idea is that the tubes will be one color when idle and another when activated.
Here's a CAD image:
I've bought this LED controller from adafruit:
https://www.adafruit.com/product/1429
As I understand it, I need to include the TLC5947 library in my above code. I think I can figure out the setup code. I'm not positive how to use the loop code. Here's a template of what each note/tube code would look like:
Code:
/// Sensor 1
if (noteIsOn1 == false) {
if (analogRead(0) > thresh) {
usbMIDI.sendNoteOn(60, random(90,120), 1);
///[B]INSERT CODE TO ACTIVATE LED COLOR FOR noteIsOn1=true[/B]
noteIsOn1 = true;
}
} else {
if (analogRead(0) < thresh) {
usbMIDI.sendNoteOff (60, 0, 1);
///[B]INSERT CODE TO ACTIVATE LED COLOR FOR noteIsOn1=false[/B]
noteIsOn1 = false;
}
}
I'm sure it's simple, but I'm not understanding what to use based on Adafruit's sample code.
Thanks much for any help!