I previously started a thread here about being unable to get a 4TRONIX ULTRASONIC DISTANCE SENSOR BREAKOUT (CE07356) working with our BitBot XL & MicroBit v1 -
Core were great & shipped a new replacement. (Thanks!) But I’m somewhat embarrassed to have to report that we are still having exactly the same problem.
Here is the program (though we have tried variants):
We’ve tried the beta of makecode as well as the normal. Photos are as per previous post.
We’ve tried to be particularly careful when handling it, so I’m confident it’s not damaged.
I’m about to head home for the day (I’m actually still here late) but now that we’ve got these on shelf I’ve grabbed some stock of the XL and the distance sensor so we can test it out tomorrow.
Well, I have good news! I’ve been able to replicate your result!
And the problem is - I think your batteries are flat
I just tried powering the BitBot with our lab supply and slowly dropped the “battery” voltage down to see where it would fail. At 2.7v (instead of the ~4.8v of 3x fully charged AA’s) the micro:bit output a constant 1 on the screen.
There must be enough voltage to keep the micro:bit running (I checked, it’ll actually keep operating down below 1.8v), but not enough to drive the Ultrasonic sensor properly - hence the erroneous reading.
The good news is that the code definitely works!
Here’s a new BitBot XL running from a power supply replicating your issue:
And here’s the code running with fresh batteries.
Please let us know how you go with a fresh set of batteries!
Fixed! You folks are genius - thanks so much for your efforts.
FYI our problem wasn’t exactly flat batteries - it was that we were using rechargeables. Apparently rechargeables produce a lower voltage. Switching to standard batteries fixed the problem.