Hi,
I plan to rebuild an old Programmer (PG300) from Roland. The Programmer was build for the Alpha Juno and send only Midi SysEx to the Alpha.
I wrote a simple code that I had found in the www.
I build the simple MIDI In circuit .
The fowling code includes 3 AnalogIn. One to select the MidiChannel and the others to control the Cutoff and the Resonance. The Code works.
Thats the first step of the project and my question: You think the code are OK or it can be more simple?
The next question: Arduino UNO have only 6 AnalogINs but I need round about 35 and more?
I have to use a Multiplexer or are there a other way to have more AnalogsINs?
/**
* MIDI Programmer
* 3 analog Potis
*
* Using code from:
* midi_cc_test.pde
* @author Benjamin Eckel
*/
#define inputs 2
#define e 1 // this is the delta needed in
// currentPot[i] to send a message
int currentPot[2] = {0,0};
int pot[2] = {0,0};
//int channel[8] = {1,2,3,4,5,6,7,8};
int Parameter = 0;
int MidiChan = 0;
int sensorReading = 0;
void setup() {
Serial.begin(31250); // baud rate = 31250 for midi
} // = 38400 for serial debug
void loop() {
for(int i=0; i<inputs; i++) {
currentPot[i] = analogRead(i);
currentPot[i] = map(currentPot[i],0,1023,0,127); //Midi read only from 0-127
// select MidiCC to right input i
Parameter = i+16;
MidiChan = analogRead(A2); //read Midi Channel
MidiChan = map(MidiChan,0,1023,0,15);
// send midi Protokoll
if(abs(currentPot[i]-pot[i]) > 1) {
SendSysEx(MidiChan,Parameter,currentPot[i]);
pot[i] = currentPot[i];
}
}
}
//Midi Protokoll
void SendSysEx(int Chan, int Par, int Value) {
//ifdef
//Serial.println(Value, DEC);
//else
Serial.write(0xF0); // SysEx start
//delay(1);
Serial.write(0x41); // Manufacturer 0
//delay(1);
Serial.write(0x36); // Model 1
//delay(1);
Serial.write(Chan); // MIDI channel
//delay(1);
Serial.write(0x23); // Data
//delay(1);
Serial.write(0x20); // Data
//delay(1);
Serial.write(0x01); // Data
//delay(1);
Serial.write(Par); // for example Cutoff Synth
//delay(1);
Serial.write(Value); // sensorValue
//delay(1);
Serial.write(0xF7); // SysEx end
//delay(1);
//Serial.begin(9600);
//Serial.println(Value, HEX);
}