may anyone pls tell me how to convert the measurement unit ?i have tried using 'microsecondsToInches' and 'microsecondsToInches', but it seem like not valid. can anyone help me ?
Please use code tags when you post code. It is the # button in the editor (if you modify your post and select the code and press # it will be done automatically)
if(Serial.available()>0)
{
int header=Serial.read(); //0x22
int highbyte=Serial.read();
int lowbyte=Serial.read();
int sum=Serial.read();//sum
You try to read 4 bytes, but you only know there are more than 0. So change this into
if(Serial.available()>=4)
{
int header=Serial.read(); //0x22
int highbyte=Serial.read();
int lowbyte=Serial.read();
int sum=Serial.read();//sum
optionally print all 4 bytes here for debug
thx very much. nw i get the value in cm after changed the code to according to yr advice. But hw to set the max range. now the max range is 70 cm even the range is 1.5 m. The user guide stated that is can support up to 0.35cm to 3m (5m depend on the situation).
What does it tell about the max range?
What does it state about the reflective surfaces needed?
According to URM37_V3.2_Ultrasonic_Sensor__SKU_SEN0001_-DFRobot there is no surfaces requirement.I think my room space is enough for the Beam Width. I will go through more materiel over internet but the information is limited. Anyway thanks for the advise.