hello,
i connect ultrasonic sensor arduino openframeworks firmata. pulling code ping , firmata examples. however, reads weird digits "üñýüüüüü" rather distance in inches.
below code , can tell me have done wrong please?
i connect ultrasonic sensor arduino openframeworks firmata. pulling code ping , firmata examples. however, reads weird digits "üñýüüüüü" rather distance in inches.
below code , can tell me have done wrong please?
code: [select]
#include <firmata.h>
const int pingpin = 7;
void setup()
{
firmata.begin();
}
void loop()
{
while(firmata.available()) {
firmata.processinput();
}
firmata.sendanalog(pingpin, computedistance());
}
long computedistance(){
long duration, inches, cm;
pinmode(pingpin, output);
digitalwrite(pingpin, low);
delaymicroseconds(2);
digitalwrite(pingpin, high);
delaymicroseconds(5);
digitalwrite(pingpin, low);
pinmode(pingpin, input);
duration = pulsein(pingpin, high);
// convert time distance
return microsecondstoinches(duration);
}
long microsecondstoinches(long microseconds)
{
return microseconds / 74 / 2;
}
// long microsecondstocentimeters(long microseconds)
// {
// return microseconds / 29 / 2;
// }
quote
can tell me have done wrong please?besides crossposting? used firmata.
Arduino Forum > Using Arduino > Programming Questions > Firmata connection with Ultrasonic sensor
arduino
Comments
Post a Comment