Arduino BT & Ping Ultrasonic Sensor

Hello Everyone,

I setup my Arduino Duemilanove with my PING Ultrasonic sensor perfectly with the code below. However, I wanted to set up my sensor using the Arduino BT. What would I need to change in my code in order to get my sensor responding. I tried various things, including changing the baud rate in the code to 115200, but nothing. Please help. Code below. Thanks again:

/* New Variables */ int delay_time = 20; // delay for this amount each write cycle. byte printing_byte = 0;

/* Ultrasound Sensor *------------------ * * Reads values (00014-01199) from an ultrasound sensor (3m sensor) * and writes the values to the serialport. * * http://www.xlab.se | http://www.0j0.org * copyleft 2005 Mackie for XLAB | DojoDave for DojoCorp * */

//

int ultraSoundSignal = 7; // Ultrasound signal pin int val = 0; int ultrasoundValue = 0; int timecount = 0; // Echo counter int ledPin = 13; // LED connected to digital pin 13

void setup() { beginSerial(9600); // Sets the baud rate to 9600 pinMode(ledPin, OUTPUT); // Sets the digital pin as output }

void loop() { timecount = 0; val = 0; pinMode(ultraSoundSignal, OUTPUT); // Switch signalpin to output

/* Send low-high-low pulse to activate the trigger pulse of the sensor * ------------------------------------------------------------------- */

digitalWrite(ultraSoundSignal, LOW); // Send low pulse delayMicroseconds(2); // Wait for 2 microseconds digitalWrite(ultraSoundSignal, HIGH); // Send high pulse delayMicroseconds(5); // Wait for 5 microseconds digitalWrite(ultraSoundSignal, LOW); // Holdoff

/* Listening for echo pulse * ------------------------------------------------------------------- */

pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input val = digitalRead(ultraSoundSignal); // Append signal value to val while(val == LOW) { // Loop until pin reads a high value val = digitalRead(ultraSoundSignal); }

while(val == HIGH) { // Loop until pin reads a high value val = digitalRead(ultraSoundSignal); timecount = timecount +1; // Count echo pulse time }

/* Writing out values to the serial port * ------------------------------------------------------------------- */

ultrasoundValue = timecount; // Append echo pulse time to ultrasoundValue

/* BEGIN EDITED CODE */

ultrasoundValue = ultrasoundValue - 14; ultrasoundValue = ultrasoundValue / 5;

if(ultrasoundValue > 127) { }

else {

printing_byte = ultrasoundValue; Serial.print(printing_byte); } /* END EDITED CODE */

/* Lite up LED if any value is passed by the echo pulse * ------------------------------------------------------------------- */

if(timecount > 0){ digitalWrite(ledPin, HIGH); }

/* Delay of program * ------------------------------------------------------------------- */

delay(40); }

Probably not related, but you never turn the LED off.