I using 5 URM37 ultrasonic connect to Duemilanove, the use the TTL signal to generate the signal.
The connection is Trigger and Enable all same pin, PWM is 3,5,6,9 and 10. After i compile and upload and connect all the 5 sensors to the arduino Duemilanove card, not problem but i cannot get any reading of the signal.
May i know what wrong is it?
below is the 5 sensors
// Pins for ultra URM37 V3.2
int ultraData[] = {3,5,6,9,10};
int ultraTrigger = 11;
int ultraEnable = 12;
int ultraPower = 8;
int ledPin = 13; // LED connected to digital pin 13
void setup() {
Serial.begin(9600); // Sets the baud rate to 9600
pinMode(ledPin, OUTPUT); // Sets the digital pin as output
}
int ping(int ultraSoundSignal){ // this function returns the time for the sensor on the given pin
int val=0;
int ultraValue=0;
int timecount=0;
// Wake up and get ready for sensing
pinMode(ledPin, OUTPUT); // Sets the digital pin as output
pinMode(ultraPower, OUTPUT);
digitalWrite(ultraPower, HIGH); // Set to HIGH to provide 5V power
pinMode(ultraEnable, OUTPUT);
digitalWrite(ultraEnable, HIGH); // Set Enable Pin to HIGH
pinMode(ultraTrigger, OUTPUT); // Switch signalpin to output
pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input
delay(200); //Give sensor some time to start up --Added By crystal from Singapo, Thanks Crystal.
/* Send high-low-high pulse to activate the trigger pulse of the sensor
* -------------------------------------------------------------------
*/
digitalWrite(ledPin,LOW);
digitalWrite(ultraTrigger, HIGH); // Send High pulse
delayMicroseconds(500);
digitalWrite(ultraTrigger, LOW); // Send low pulse
delayMicroseconds(200);
digitalWrite(ultraTrigger, HIGH); // Send High pulse
delayMicroseconds(200);
/* Listening for echo pulse
* -------------------------------------------------------------------
*/
do{
val = digitalRead(ultraSoundSignal); // Append signal value to val
}while(val == HIGH); { // Loop until pin reads a high value
do{
val = digitalRead(ultraSoundSignal);
timecount ++;
delayMicroseconds(50);
}while(val == LOW); // Loop until pin reads a high value
ultraValue=timecount;
//val = digitalRead(ultraSoundSignal);
// Count echo pulse time
return timecount ;
// Turn the lights out when you leave...
digitalWrite(ultraTrigger,LOW);
digitalWrite(ultraEnable,LOW);
digitalWrite(ultraPower,LOW);
}
}
void loop() {
int ultraValue;
int i;
for(i=0; i < 5; i++){
ultraValue = ping(ultraData[i]);
// Serial.write('A + i'); // Example identifier for the sensor
Serial.println(ultraValue);
Serial.write(10);
Serial.write(13);
}
/* Delay of program
* -------------------------------------------------------------------
*/
delay(10);
}
Thanks