Hi, thanks for the quick reply, i tried autoformating it, and i have now changed Serial.print, to serial.write, and it is now working with serial to midi convertor, but it doesn't seem to be outputting useable note data. And when i try it again with hairless its still sending a lot of random messages. Im afraid i don't understand what you mean about the sender, should i delete coming from that?
Here is the new code
/* Codeist , Midi Gloves and Shoes,
Callan Marchetti , Sam Cocks , Conor Matheson */
/*This code sends MIDI messages using electrical pulses from FSRs (Force Sensitive Resistors) placed in the toes of shoes and also a resistance change using LDR's in a pair of gloves
It has been adapted from code by Thobson 'Midi Shoes'
/************************************************************/
// when the upper threshold is passed a hit is trigered and when the value sinks below the lower threshold another hit is triggered. "HYSTERESIS" makes sure multiple hits arent triggered
#define FINGERTHRESHOLD 400
#define LOWERFINGERTHRESHGHOLD 6
#define TOETHRESHOLD 350
#define LOWERTOETHRESHOLD 101 // We're setting both a lower and an upper threshold for the FSRs, so that they will only trigger a MIDI message when we actually want them too.
#define LHPOINTPIN 0
#define LHMIDPIN 1
#define LHRINGPIN 2
#define LHPINKYPIN 3
#define RHPINKYPIN 4
#define RHRINGPIN 5
#define RHMIDPIN 6
#define RHPOINTPIN 7
#define TOE1PIN 8
#define TOE2PIN 9
// Define which analog in pins on the arduino we'll be using
int pinNote[10] = {
78,65,88,59,41,42,46,49,73,57}; // This array stores the different MIDI notes that each pin is assigned , do we need this?
boolean lhpoint = false;
boolean lhmid = false;
boolean lhring = false;
boolean lhpinky = false;
boolean rhpinky = false;
boolean rhring = false;
boolean rhmid = false;
boolean rhpoint = false;
boolean toe1 = false;
boolean toe2 = false; //These variables will help us to make sure we don't send multiple MIDI messages per single hit
void setup(void) {
Serial.begin(57600); // We'll send debugging information to the Serial monitor
}
void loop(void) { // This is the main function that executes all the others.
lhpoint = sender((analogRead(LHPOINTPIN)), LHPOINTPIN, pinNote[LHPOINTPIN], "", lhpoint, FINGERTHRESHOLD, LOWERFINGERTHRESHGHOLD);
lhmid = sender((analogRead(LHMIDPIN)), LHMIDPIN, pinNote[LHMIDPIN], "", lhmid, FINGERTHRESHOLD, LOWERFINGERTHRESHGHOLD);
lhring = sender((analogRead(LHRINGPIN)), LHRINGPIN, pinNote[LHRINGPIN], "", lhring, FINGERTHRESHOLD, LOWERFINGERTHRESHGHOLD);
lhpinky = sender((analogRead(LHPINKYPIN)), LHPINKYPIN, pinNote[LHPINKYPIN], "", lhpinky, FINGERTHRESHOLD, LOWERFINGERTHRESHGHOLD);
rhpinky = sender((analogRead(RHPINKYPIN)), RHPINKYPIN, pinNote[RHPINKYPIN], "", rhpinky, FINGERTHRESHOLD, LOWERFINGERTHRESHGHOLD);
rhring = sender((analogRead(RHRINGPIN)), RHRINGPIN, pinNote[RHRINGPIN], "", rhring, FINGERTHRESHOLD, LOWERFINGERTHRESHGHOLD);
rhmid = sender((analogRead(RHMIDPIN)), RHMIDPIN, pinNote[RHMIDPIN], "", rhmid, FINGERTHRESHOLD, LOWERFINGERTHRESHGHOLD);
rhpoint = sender((analogRead(RHPOINTPIN)), RHPOINTPIN, pinNote[RHPOINTPIN], "", rhpoint, FINGERTHRESHOLD, LOWERFINGERTHRESHGHOLD);
toe1 = sender((analogRead(TOE1PIN)), TOE1PIN, pinNote[TOE1PIN], "", toe1, TOETHRESHOLD, LOWERTOETHRESHOLD);
toe2 = sender((analogRead(TOE2PIN)), TOE2PIN, pinNote[TOE2PIN], "TOE2", toe2, TOETHRESHOLD, LOWERTOETHRESHOLD);
}
void midimsg(unsigned char message, unsigned char pitch, unsigned char velocity) { // This function sends a MIDI message with a message, pitch, and velocity
Serial.write(message);
Serial.write(pitch);
Serial.write(velocity);
}
boolean sender(int reading, int pin, int note, char msg[], boolean press, int threshold, int lowerthreshold ) { // This function is what does all the work
if(reading <= threshold) { // If the user stomps harder than a certain threshold...
if(!press) { // and if the sensor is not already in 'pressed' mode...
reading = reading/8 - 1; // convert the FSR reading to a MIDI-friendly value
midimsg(144, note, 128); // Send a MIDI message
Serial.println(msg); // Send a unique debug message to the Serial monitor
delay(100);
}
press = true; // The sensor is now in 'pressed' mode,
}
else if(reading >= lowerthreshold) { // once the applied force sinks below the lower threshold...
if(press)
midimsg(128,note,0);
press = false; // the sensor is no longer in 'pressed' mode
}
return press;
}