background image

 

Download the sample code to the Arduino board, then wire as shown modules and Arduino 
connected on ultrasonic distance measurement can be achieved.

Note

:download first before connect 

the Arduino TX/RX, or download will failed.  

Demo Code

 

 1        //Put your code here 

 2  

 3 // # Editor    :Zrh from DFRobot 

 4 // # Data      :29.08.2014 

 5 // # Product name:ultrasonic scanner  

 6 // # Product SKU:SEN0001 

 7 // # Version :  1.0 

 8   

 9 // # Description: 

10 // # The sketch for using the URM37 autonomous  mode from DFRobot   

11 // #   and writes the values to the serialport 

Содержание SEN0001

Страница 1: ...rvo Rotation Reference Table 5 Protocol 6 Trouble shooting 7 More Introduction URM37 V4 0 Ultrasonic Sensor uses an industrial level AVR processor as the main processing unit It comes with a temperatu...

Страница 2: ...reboot Modified the algorithm so dead zone was reduced and enhance accuracy Analog voltage output voltage and the measured distance is proportional Wide voltage support 3 3V 5 0V Power reverse protect...

Страница 3: ...have to set the serial port level or RS232 TTL level then we can access to the module through the serial port then set the range mode 0x02 writes data on the internal EEPROM address after that you can...

Страница 4: ...off from state on release the botton Repower again he Indicator appears to flash like once long and once short present TTL level output once long and twice short flash presenting RS232 level Do not c...

Страница 5: ...iagram RS232 Mode Connection Diagram Power on the sensor read the blink of the LED active to get the serial level see above wire according to the above picture After this you can use our URMV3 2HelpMa...

Страница 6: ...ut the meaning of the data in EEPROM several addresses For more details can be found in the Serial control protocol part Address Meaning 0x00 larger than set distance 0x01 less than set distance 0x02...

Страница 7: ...ress are unavailable 0x00 0x04 please do not try to modify the data Three Measure Modes PWM trigger mode In PWM trigger mode pin COMP TRIG produces a low level of triggered pulse signal starting dista...

Страница 8: ...Arduino Pin 2 GND URM V4 0 16 Pin 3 Arduino Pin 4 ECHO URM V4 0 17 Pin 5 Arduino Pin 6 COMP TRIG URM V4 0 18 Pin A0 Arduino Pin 7 DAC URM V4 0 19 Working Mode PWM trigger pin mode 20 21 define Measure...

Страница 9: ...a low pull on pin COMP TRI G triggering a sensor reading 47 48 Serial print Distance Measured 49 digitalWrite URTRIG LOW 50 digitalWrite URTRIG HIGH reading Pin PWM will output pulses 51 if Measure 52...

Страница 10: ...orPin 67 if sensorValue 10 the reading is invalid 68 69 Serial print Invalid 70 71 else 72 sensorValue sensorValue 0 718 73 Serial print sensorValue 74 Serial println cm 75 76 77 result Open the IDE s...

Страница 11: ...de By means of the computer software or MCU Module write 0xAA to 0x02 address to switch to automatic measurement mode Writting a 8 bit 16 binary data to 0x04 address to reverse the measure time interv...

Страница 12: ...Note download first before connect the Arduino TX RX or download will failed Demo Code 1 Put your code here 2 3 Editor Zrh from DFRobot 4 Data 29 08 2014 5 Product name ultrasonic scanner 6 Product SK...

Страница 13: ...25000US Every 50US represent 1cm 23 24 unsigned int Distance 0 25 uint8_t EnPwmCmd 4 0x44 0x02 0xaa 0xf0 distance measure command 26 27 void setup Serial initialization 28 Serial begin 9600 Sets the...

Страница 14: ...ured 45000 the reading is invalid 47 Serial print Invalid 48 49 else 50 Distance DistanceMeasured 50 every 50us low level stan ds for 1cm 51 Serial print Distance 52 Serial print Distance 53 Serial pr...

Страница 15: ...ent intervals set serial port set RS232 or TTL reboot to take effect e g 1 Read the temperature data command 0x11 0x00 0x00 0x11 2 Read the distance data command 0x22 0x00 0x00 0x22 3 Read EEPROM data...

Страница 16: ...2 13 Connection 14 Vcc Arduino Pin 1 VCC URM V4 0 15 GND Arduino Pin 2 GND URM V4 0 16 Pin TX1 Arduino Pin 8 RXD URM V4 0 17 Pin RX0 Arduino Pin 9 TXD URM V4 0 18 Working Mode Serial Mode 19 20 uint8_...

Страница 17: ...mpCmd i 39 40 while Serial available 0 if serial receive any data 41 42 for i 0 i 4 i 43 TempData i Serial read 44 45 TempValue TempData 1 8 46 TempValue TempValue TempData 2 47 Serial print temperatu...

Страница 18: ...degrees Celsius Servo Rotation Reference Table Servo control command reference table DEC 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 HEX 0 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F Degree 0 6 12 18 24 29...

Страница 19: ...8 39 40 41 42 43 44 45 46 HEX 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E Degree 188 194 200 206 211 217 223 229 235 241 247 252 258 264 270 Arduino Sketch NOTE Please put the sensor jumpers to TTL m...

Страница 20: ...TL mode You ll also find a secondary jum per on the left hand side you must break this connection or you may damage you r device include Servo h Include Servo library Servo myservo create servo object...

Страница 21: ...erval 0 02 seconds time millis get the current time o f programme if up judge the condition if pos 0 pos 179 pos pos 1 in steps of 1 degree myservo write pos tell servo to go to po sition in variable...

Страница 22: ...id PWM_Mode a low pull on pin COM P TRIG triggering a sensor reading digitalWrite URTRIG LOW digitalWrite URTRIG HIGH reading Pin PWM will output pulses unsigned long DistanceMeasured pulseIn URPWM LO...

Страница 23: ...t four bits of High will be all 0 If the temperature is below 0 the first four bits of High will be all 1 The last 4 bits of High together with the Low bits stands for 12bits temperature The resolutio...

Страница 24: ...to use it please first check the current serial port level mode it may be in TTL level while our module works in RS232 levels 2 The ultrasonic attenuation violently in the air inversely proportional t...

Страница 25: ...More Arduino Library from milesburton IDE 0023 and below Old version_URM37 V3 2 Powered By DFRobot 2008 2016...

Отзывы: