firmata, ping sensor, arduino, and OF problem
i coming pure data had ping sensor sending distance in inches pure data used distance information play video , different speeds.
i'd same in of because of handles video better.
i getting hung on getting arduino send distance information of. distance in inches should show in serial monitor of arduino software, jumble data.
here code have on arduino (.pde file):
once distance data show in serial monitor firmata, move on getting of read data.
i have scoured internet examples deal analog data. ping sensor digital need able receive digital data in of...
any insights appreciated!!
thanks
tim
i'd same in of because of handles video better.
i getting hung on getting arduino send distance information of. distance in inches should show in serial monitor of arduino software, jumble data.
here code have on arduino (.pde file):
code: [select]
#include <firmata.h>
byte digitalpin;
char firstchar;
char secondchar;
int pingpin = 7;
void digitalwritecallback(byte pin, int value)
{
pinmode(pin,output);
analogwrite(pin, value);
}
void setup()
{
firmata.setfirmwareversion(0, 1);
firmata.attach(analog_message, digitalwritecallback);
firmata.begin();
}
void loop()
{
while(firmata.available()) {
firmata.processinput();
}
for(digitalpin = 0; digitalpin < total_digital_pins; digitalpin++) {
if(digitalpin == 7)
firmata.senddigitalport(digitalpin, computedistance());
}
}
long computedistance(){
long duration, inches, cm;
// ping))) triggered high pulse of 2 or more microseconds.
// give short low pulse beforehand ensure clean high pulse.
pinmode(pingpin, output);
digitalwrite(pingpin, low);
delaymicroseconds(2);
digitalwrite(pingpin, high);
delaymicroseconds(5);
digitalwrite(pingpin, low);
// same pin used read signal ping))): high
// pulse duration time (in microseconds) sending
// of ping reception of echo off of object.
pinmode(pingpin, input);
duration = pulsein(pingpin, high);
// convert time distance
return microsecondstoinches(duration);
//cm = microsecondstocentimeters(duration);
}
long microsecondstoinches(long microseconds)
{
// according parallax's datasheet ping))), there are
// 73.746 microseconds per inch (i.e. sound travels @ 1130 feet per
// second). this gives distance travelled ping, outbound
// , return, divide 2 distance of obstacle.
return microseconds / 74 / 2;
}
long microsecondstocentimeters(long microseconds)
{
// speed of sound 340 m/s or 29 microseconds per centimeter.
// ping travels out , back, find distance of the
// object take half of distance travelled.
return microseconds / 29 / 2;
}
once distance data show in serial monitor firmata, move on getting of read data.
i have scoured internet examples deal analog data. ping sensor digital need able receive digital data in of...
any insights appreciated!!
thanks
tim
Arduino Forum > Forum 2005-2010 (read only) > Software > Interfacing > firmata, ping sensor, arduino, and OF problem
arduino
Comments
Post a Comment