I found a project I hope to build so today I sat down to study the files
and have ended up very confused over one part.
The project is “MIDI Mule – A small MIDI foot controller”.
Info is available at Midi Mule – thoro.de.
“In the define analog pins for LEDs” what's happening with 10,11?
Thanks for your help. I am still very new to Arduino.
Hutzpah
#include "Arduino.h"
#include "Switch.h"
#include "MIDI.h"
// Define analog pins for LEDs
int ledPin1 = A0;
int ledPin2 = A1;
int ledPin3 = A2;
int ledPin4 = A3;
int ledPin5 = A4;
int ledPin6 = A5;
int ledPin7 = 10; // Workaround, A6 just works as digital input
int ledPin8 = 11; // Workaround, A7 just works as digital input
// Switches
Switch buttonGND1 = Switch(2); // button to GND, use internal 20K pullup resistor
Switch buttonGND2 = Switch(3); // button to GND, use internal 20K pullup resistor
Switch buttonGND3 = Switch(4); // button to GND, use internal 20K pullup resistor
Switch buttonGND4 = Switch(5); // button to GND, use internal 20K pullup resistor
Switch buttonGND5 = Switch(6); // button to GND, use internal 20K pullup resistor
Switch buttonGND6 = Switch(7); // button to GND, use internal 20K pullup resistor
Switch buttonGND7 = Switch(8); // button to GND, use internal 20K pullup resistor
Switch buttonGND8 = Switch(9); // 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);
}