i have 2 sets of 7 leds each. each set is working when receiving midi note cc20 and cc21
problem is that if for example midi cc21 stop coming in, then the leds that was on, they stay on till they get a new cc21 note.
is there a way to make it when there is no midi massage for 1 sec to turn the leds off, and if midi note come again to start leds working again.
void VUmeter_LEFT_OR_RIGHT(byte channel, byte CC, byte val) {
for (int i = 0; i < 6; i++) { //leds in this Vu left deck or deckA
registers[i] = LOW;
}
for (int i = 7; i < 14; i++) { //leds in this Vu right deck or deckb
registers[i] = LOW;
// registers[7] = HIGH;
}
if (CC == 21) { // light leds when receiving a cc note 21
for (int i = 0; i < 7; i++) { //leds based on Vu number from midi in
VuBuff[i] = LOW;
}
for (int i = 0; i < val; i++) { //leds based on Vu number from midi in
VuBuff[i] = HIGH;
}
}
if (CC == 20) { // light leds when receiving a cc note 20
for (int i = 0; i < 7; i++) { //leds based on Vu number from midi in
VuBuff[(9 + i) - 2] = LOW;
// VuBuff[7] = HIGH;
}
for (int i = 0; i < val; i++) { //leds based on Vu number from midi in
VuBuff[(9 + i) - 2] = HIGH;
// VuBuff[7] = HIGH;
}
}
for (int i = 0; i < 7; i++) { //leds based on Vu number from midi in
registers[i] = VuBuff[i];
updateSR();
}
for (int i = 7; i < 14; i++) { //leds based on Vu number from midi in
registers[i] = VuBuff[i];
updateSR();
}
}
Save the value of millis() when a MIDI message is received then, each time round loop() test whether 1 second has passed (current millis() - saved millis() >= 1 second) and if so then turn off the LEDs
now i make a second thought i realize it cant work what i want to do. because the button is choosing the function where to send the midi note. if send midi to MIDI.setHandleControlChange(VUmeter_main); and leds light and then press the button and switch to MIDI.setHandleControlChange(VUmeter_LEFT_OR_RIGHT);
then leds that are stay on to turn them off in (vumeter_main) they need to get a command
Ch 1: Controller 23 value 0
but there is no way to pass this massage because the MIDI.setHandleControlChange(VUmeter_LEFT_OR_RIGHT); is chosen that it listen in deferent message.
Ch 1: Controller 20 value 0
and also midi message will never stop to come in to the Arduino because there no way to tell to the software (trakror) to stop sending the midi message so ma asking was falls from the first place.
void VUmeter_main(byte channel, byte CC, byte val) {
for (int i = 0; i < 6; i++) { //leds in this Vu
registers[i] = LOW;
}
for (int i = 7; i < 14; i++) { //leds in this Vu
registers[i] = LOW;
// registers[7] = HIGH;
}
if (CC == 23) { // light leds when volume changes
for (int i = 0; i < 7; i++) { //leds based on Vu number from midi in
VuBuff[i] = LOW;
}
for (int i = 0; i < val; i++) { //leds based on Vu number from midi in
VuBuff[i] = HIGH;
}
}
if (CC == 22) { // light leds when volume changes
for (int i = 0; i < 7; i++) { //leds based on Vu number from midi in
VuBuff[(9 + i) - 2] = LOW;
// VuBuff[7] = HIGH;
}
for (int i = 0; i < val; i++) { //leds based on Vu number from midi in
VuBuff[(9 + i) - 2] = HIGH;
// VuBuff[7] = HIGH;
}
}
for (int i = 0; i < 7; i++) { //leds based on Vu number from midi in
registers[i] = VuBuff[i];
updateSR();
}
for (int i = 7; i < 14; i++) { //leds based on Vu number from midi in
registers[i] = VuBuff[i];
updateSR();
}
}