I have a SRF05 ultrasonic sensor mounted to a wireless robot. The signal from the SRF05 is run into a Arduino Duemilanove board. I am able to monitor the change is distance of a object from the serial monitor. My problem is that I would like to send this value to a the Java page so the distance can be monitored while the robot is in use. My problem is I am unsure of how to get the value out of the Duemilanove board? Here is a program that I am working with,
int duration; // Stores duratiuon of pulse in
int distance; // Stores distance
int srfPin = 2; // Pin for SRF05
int outPin = 3; // Output Pin for SRF05!!
pinMode(outPin, OUTPUT); // Initialize pin 3 as output!!
digitalWrite(srfPin, LOW); // Make sure pin is low before sending a short high to trigger ranging
digitalWrite(srfPin, HIGH); // Send a short 10 microsecond high burst on pin to start ranging
digitalWrite(srfPin, LOW); // Send pin low again before waiting for pulse back in
duration = pulseIn(srfPin, HIGH); // Reads echo pulse in from SRF05 in micro seconds
distance = duration/58; // Dividing this by 58 gives us a distance in cm
digitalWrite(outPin, HIGH); // Writes value to outPin 3!!
delay(50); // Wait before looping to do it again
I added in the code for the output pin and labeled it with "!!".