IR DISTANCE to MIDI - Help


hello everyone. using noah stahls code attempt take data long range ir distance , spit out midi cc. have searched forums, interwebs, etc, , nothing. have tried various approaches, figured post below code basic beginnings can see going wrong @ start....

noah's code (in original rendition) spitting out data in inches (which come close enough 0-127)
and have run midi example make sure im outputting out of tx-1 , through midi interface.

any appreciated, please beware dealing absolute beginner!

thanks team

james

code: [select]
//  noah stahl
//  5/25/2011
//  http://arduinomega.blogspot.com
//  arduino mega 2560
//this sketch used test sharp long range infrared sensor.
//the sensor output attached analog pin 15. once distance
//is calculated, printed out serial monitor.

#define sensorir 1               //must analog pin
float sensorvalue, inches, cm;    //must of type float 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);
}

quote
serial.print(0xb0);
  serial.print("inches: ");
  serial.print(127);

printing strings midi output going screw up.
using serial.print going screw up.
use
code: [select]
serial.write(0xb0); // cc message channel 1
  serial.write(0x5); // or ever cc number want write to
  serial.write(inches & 0x7f); // keep inches going on 127



Arduino Forum > Using Arduino > Audio > IR DISTANCE to MIDI - Help


arduino

Comments

Popular posts from this blog

Thread: PKI Client 5.00 install (for eToken Pro)

ATmega2560-Arduino Pin Mapping

Crossfader Arduino Tutorial