Topic: SRF05 output
(Read 2086 times)
Jun 08, 2011, 03:31 pm
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 "!!".
Re: SRF05 output
Jun 09, 2011, 11:27 pm
You are outputting the values via the serial port - presume you need to interface Java to the serial port - try googling for 'java serial interface' and have a look at gnu.io.serialport
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]