Hello Everyone. I am using Noah Stahls code to attempt to take data from a long range ir distance and spit it out as a midi cc. I have searched forums, interwebs, etc, and nothing. I have tried various approaches, but figured I would just post the below code as its the basic beginnings so I can see where I am going wrong even at the start....
Noah's code (in its original rendition) is spitting out data perfectly in inches (which come close enough to 0-127)
And I have successfully run the midi example to make sure im outputting properly out of tx-1 and through the midi interface.
Any help would be greatly appreciated, but please beware you are dealing with an absolute beginner!
Thanks team
James
// Noah Stahl
// 5/25/2011
// http://arduinomega.blogspot.com
// Arduino Mega 2560
//This sketch is used to test the Sharp Long Range Infrared Sensor.
//The sensor output is attached to analog pin 15. Once the distance
//is calculated, it is printed out to the serial monitor.
#define sensorIR 1 //Must be an analog pin
float sensorValue, inches, cm; //Must be of type float for pow()
void setup() {
Serial.begin(31250);
}
void loop() {
sensorValue = analogRead(sensorIR);
inches = 4192.936 * pow(sensorValue,-0.935) - 3.937;
//cm = 10650.08 * pow(sensorValue,-0.935) - 10;
delay(100);
Serial.print(0xb0);
Serial.print("inches: ");
Serial.print(127);
}