mBot UltraSonic sensor doesn't work


#1

Before I start: I had to recreate the pre-installed software of the mBot, since I tried uploading some test code, then realizing afterwards that there was no way to restore factory settings. Uups! :flushed:

After reload, I had all buttons active back again. Mode A and C work, mode B doesn’t.

The robot starts by moving backwards, as if it has ran into some obstacle. Moving my hand some 2-3 cm in front of the two sensors doesn’t change this, until I close the opening of any one of the sensors. Now the robot goes forward!!?
Did I mention that re-checked the cables? Everything seems correct!

I tried some sample code shown for the UltraSonic sensor from the Makeblock wiki. The console output shows constance distance of 0cm!
I seem to have version 3 of the sensor, and the wiki is about version 2! Not sure if this would make any difference.
Looking into the mBot code (Mode B part), it looks slightly different to the sample code for sensor version 2, so maybe I need a different one.

Any idea what is wrong?


#2

I have now re-created the mBot factory settings, and the sensor works.
So maybe I’m just using the wrong sample code for the sensor from the Makeblocks wiki.

I’ll come back as soon as I figured out how to code the sensor version 3.


#3

Ok, so I realize that now the code sample from the UltraSonic sensor wiki page works.
I guess re-creating of the mBot factory settings uploaded new libraries to the mBot…

Watching the serial output, I realize that quite often I can see zero values.


Is this something desirable? No, right? This is weird!
Any ideas why this is so?


#4

@HIP70890, thanks for your feedback, could you please send email to support@makeblock.cc, our support would help to solve the problem.


#5

As soon as I include a reference to the ultrasonic sensor, I get this error:
7-5 14:24: ####Error####
core.a(wiring_pulse.c.o): In function pulseIn': /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino/wiring_pulse.c:48: undefined reference tocountPulseASM’
collect2: error: ld returned 1 exit status

7-5 14:24: Process exited with 1


#6

@bhamilton2591, could you please kindly send your email to our support? here is the email address: support@makeblock.cc


#7

I’ve discovered that even thought\ the compiler reports an error, the code is uploaded and the mBot executes correctly. Which is strange…


#8

@bhamilton2591, Seen from what you have sent, the problem should come from the version of Arduino IDE you are using. It says ā€œcountPulseASMā€ is not defined in the ā€œwiring_Pulse.cā€ file. Please download the newest version, make sure the file is included and try again.


#9