Hello!
My project involves reading the analog input resistance values and when they get to a certain input they send a midi note to a converter on my computer and it plays a note through garage band. I found a way to make one analog input work and now i want to have as many as i can. I am using the arudion uno R3, any help for the best way to do this would be great! Here is my code
#include <MovingAvarageFilter.h>
const int MIDI_ON =144;
const int MIDI_OFF= 128;
const int MIDI_CHANNEL= 0;
MovingAvarageFilter movingAvarageFilter(20);
boolean check = false;
void setup() {
Serial.begin(115200);
}
void loop() {
// declare input and output variables
float input = analogRead(0); // without a real input, looking at the step respons (input at unity, 1)
float output = 0;
output = movingAvarageFilter.process(input);
// here we call the fir routine with the input. The value 'fir' spits out is stored in the output variable.
if (output < 1000 ) { // you can change this parameter to fine tune the sensitivity
if (!check){
midiSend (MIDI_ON, 90, 100);
//Keyboard.print("d");
//Serial.println(output);
check = !check;
//Serial.println (output);
}
}
if (output >1015) {
//Serial.println ("output >900");
//Serial.println (output);
if (check){
midiSend (MIDI_OFF, 90, 100);
check = !check;
}
}
}
void midiSend( int cmd, int data1, int data2 )
{
Serial.write( cmd );
//Serial.write(' ');
Serial.write( data1 );
//Serial.write(' ');
Serial.write( data2 );
//Serial.println();
}