Hello
This is my first post at Arduino Forums.
I bough a Ping))) Ultrasonic Sensor from Parallax.
I'm trying to play a video with Processing when an object comes at 10 cm or less from the sensor via the serial signal.
The Ping Library works fine when printing the distances and time on the serial monitor.
Then I'm using this code to make a On/Off switch on the Arduino IDE:
#include <Ping.h>
Ping ping = Ping(7,0,0);
boolean play;
void setup(){
play = 0;
Serial.begin(9600);
}
void loop(){
ping.fire();
if (ping.centemeters() < 10)
{
play = true;
Serial.print(play);
Serial.println();
delay(1000);
}
else
{
play = false;
Serial.print(play);
Serial.println();
delay(1000);
}
}
I have no errors when compiling or uploading to the Duemilanove. The problem is that nothing prints on the Serial Monitor. I can see some data is being parsed because the scroll bar moves. But I don't see any 1s/0s or Truths/Fakes.
¿What's wrong with my code?
Thanks in advanced.