hmm i still find it all a bit confusing.
I know i have to get the numbers representing the range from the rangefinder (it is in inches).
I found this code which apparently works with the maxbotix ez1 that i have:
//Output
int statusLed = 13;
//intput
int ez1Analog = 0;
void setup() {
pinMode(statusLed,OUTPUT);
pinMode(ez1Analog,INPUT);
beginSerial(9600);
}
void loop() {
int val = analogRead(ez1Analog);
if (val > 0) {
// The Maxbotix reports 512 steps of information on AN
// but we read that as 1024. Each step is 1", so we need
// to divide by 2 to get the correct rough range in inches.
//
// this value should also be calibrated for your particular
// sensor and enclosure
val = val / 2;
Serial.println(val); // inches
}
blinkLed(statusLed,100);
}
void blinkLed(int pin, int ms) {
digitalWrite(pin,LOW); // turn it off it was on
digitalWrite(pin,HIGH);
delay(ms);
digitalWrite(pin,LOW);
delay(ms);
}
i assume that makes the LED blink at variable speeds according to the range.
so that is getting to where i need, but instead of changing the speed of the led, i need it to change the value of the parameter on the pitch on max.
this is what my simple max synth looks like now...
i need to automate the top parameter with the data from the rangefiner.
i have no idea how to incorperate that parameter with the arduino...
its kinda hurting my head. ha
cheers
dave