The midi foot switch I made is only sending “Reset” command.
I have made a midi foot switch using an Aduino nano and following
the project on Midi Mule at https://thoro.de/en/guitars/midi_mule/.
With the help of ToddL1962 the lights and switchers are working in tandem now.
The foot switch is now working sending message's to Gmidimonitor in Linux.
But the problem is that its only sending a command call “Reset”.
I can use midi meaning to capture that one command to turn on one switch only.
As the other 7 switchers on the midi foot controller send the same signal “Reset”.
What's wrong?
I did not write the code.(I am only just now starting to learn a bit of coding)
Any help would be much appreciated.
Hutzpah
#include "Arduino.h"
#include "avdweb_Switch.h"
#include "MIDI.h"
// Define analog pins for LEDs
int ledPin1 = 10; // Workaround, A6 just works as digital input
int ledPin2 = 11; // Workaround, A7 just works as digital input
int ledPin3 = A5;
int ledPin4 = A4;
int ledPin5 = A3;
int ledPin6 = A2;
int ledPin7 = A1;
int ledPin8 = A0;
// Switches
Switch buttonGND1 = Switch(8); // button to GND, use internal 20K pullup resistor
Switch buttonGND2 = Switch(9); // button to GND, use internal 20K pullup resistor
Switch buttonGND3 = Switch(2); // button to GND, use internal 20K pullup resistor
Switch buttonGND4 = Switch(3); // button to GND, use internal 20K pullup resistor
Switch buttonGND5 = Switch(4); // button to GND, use internal 20K pullup resistor
Switch buttonGND6 = Switch(5); // button to GND, use internal 20K pullup resistor
Switch buttonGND7 = Switch(6); // button to GND, use internal 20K pullup resistor
Switch buttonGND8 = Switch(7); // button to GND, use internal 20K pullup resistor
// MIDI init
MIDI_CREATE_DEFAULT_INSTANCE();
void setup() {
// Set serial baud rate: 31200 for MIDI / 9600 for debugging
// Serial.begin(31200);
MIDI.begin(1); // Launch MIDI and listen to channel 1
}
void loop() {
buttonGND1.poll();
if(buttonGND1.released()) {
// Serial.write("Button 1\n");
MIDI.sendProgramChange(0,1); // Send the MIDI command
ledOffAll();
analogWrite(ledPin1, 255);
}
buttonGND2.poll();
if(buttonGND2.released()) {
// Serial.write("Button 2\n");
MIDI.sendProgramChange(1,1); // Send the MIDI command
ledOffAll();
analogWrite(ledPin2, 255);
}
buttonGND3.poll();
if(buttonGND3.released()) {
// Serial.write("Button 3\n");
MIDI.sendProgramChange(2,1); // Send the MIDI command
ledOffAll();
analogWrite(ledPin3, 255);
}
buttonGND4.poll();
if(buttonGND4.released()) {
// Serial.write("Button 4\n");
MIDI.sendProgramChange(3,1); // Send the MIDI command
ledOffAll();
analogWrite(ledPin4, 255);
}
buttonGND5.poll();
if(buttonGND5.released()) {
// Serial.write("Button 5\n");
MIDI.sendProgramChange(4,1); // Send the MIDI command
ledOffAll();
analogWrite(ledPin5, 255);
}
buttonGND6.poll();
if(buttonGND6.released()) {
// Serial.write("Button 6\n");
MIDI.sendProgramChange(5,1); // Send the MIDI command
ledOffAll();
analogWrite(ledPin6, 255);
}
buttonGND7.poll();
if(buttonGND7.released()) {
// Serial.write("Button 7\n");
MIDI.sendProgramChange(6,1); // Send the MIDI command
ledOffAll();
analogWrite(ledPin7, 255);
}
buttonGND8.poll();
if(buttonGND8.released()) {
// Serial.write("Button 8\n");
MIDI.sendProgramChange(7,1); // Send the MIDI command
ledOffAll();
analogWrite(ledPin8, 255);
}
}
void ledOffAll() {
analogWrite(ledPin1, 0);
analogWrite(ledPin2, 0);
analogWrite(ledPin3, 0);
analogWrite(ledPin4, 0);
analogWrite(ledPin5, 0);
analogWrite(ledPin6, 0);
analogWrite(ledPin7, 0);
analogWrite(ledPin8, 0);
}