Hi,
does someone have a sketch for reading the URM37 via PWM?
I found one example with 4 sensors and tried to adapt it for one. But I only get one reading. Then the arduino seems to freeze.
I don't get it to work. Maybe I also need to set it to PWM mode but I think it comes with PWM mode enabled by default. Also tried it like this:
// set URM37 to PWM
// # Connection:
// # Pin12 (Arduino) -> Pin 1 VCC (URM V3.2)
// # GND (Arduino) -> Pin 2 GND (URM V3.2)
// # Pin 0 (Arduino) -> Pin 9 TXD (URM V3.2)
// # Pin 1 (Arduino) -> Pin 8 RXD (URM V3.2)
// #
int URPower = 12; // Ultrasound power pin
int val = 0;
int USValue = 0;
int timecount = 0; // Echo counter
boolean flag=true;
uint8_t DMcmd[4] = {
0x44, 0x02, 0xbb, 0x01}; //set PWM mode
void setup() {
Serial.begin(9600); // Sets the baud rate to 9600
Serial.println("Init the sensor");
pinMode(URPower, OUTPUT);
digitalWrite(URPower, HIGH); // Set to High
delay(200); //Give sensor some time to start up
}
void loop()
{
for(int i=0;i<4;i++)
{
Serial.write(DMcmd[i]);
}
delay(20);
}
I hope someone can help. With TTL/SoftwareSerial I get problems with my servo.
(http://arduino.cc/forum/index.php/topic,110835.0.html)
Thanks
Robert