Hi, I recently got my Pico 4wd and Everything seems to be working fine I even made my own code to avoid walls but when my sonar tried to sense the wall it is getting -0.034, and then the distance and then -0.034 this is slowing my detection rate drastically do yall have any way of fixing this ?.
1, please make sure the wiring of the ultrasonic sensor is correct
2、You go to execute test_sonar.py script to see the print information.
3、What code are you executing? We suggest you provide the code to us so that we can analyze and solve the problem.
apparently the indents in my code don’t show so I will send the google doc
This may be the case that you detect the ultrasonic sensor reading value too fast, did not give the detection delay, you have to give the ultrasonic detection plus delay, can not be less than 0.02s.
dear sun founder thx for the reply
I have tried to run test. sonar and it works perfectly but in my code, it still prints -0.034 even though I put the sleep time to 1
these are the results of test.sonar
meanwhile, these are the results for the updated code in which the time.sleep is 1
I also updated the code in the document if you want to check that out
Send us your updated code so we can analyze the problem.
it is in the document
the same one that I sent before
You need to add a delay after each read and that will fix it.
BTW, we modified your code for you, the code file was sent to you via forum private message.