In a previous post I related how I used the tilt function of the micro:Bit to control the direction a Robot Cart moved. It worked ok although a little inaccurate. But my grandkids had fun with it.
I then wondered if using the compass could be used to turn the Cart. My plan was to detect when the compass had changed direction and command the Cart to turn in that direction. It has not been successful, the following are my findings.
The compass direction can vary by up to 10 degrees just sitting on the bench
Two micro:Bits can have a different idea of where North it. Variation was out by about 20 degrees. But suspect the battery pack being close to one of the micro:Bits affected its calibration.
The calibration animation can be annoying after a few times. Once the calibration is saved it works good. But the message scrolling is the annoying part, especially if you don’t get all the LEDs lit quick enough.
The problem is developing an algorithm that can determine the current rest position and then detect a variation from that position. While ignoring the up to 10 degree variation jitter. And at the same time updating the rest position if the orientation of the micro:Bit is changed. I think it is beyond my programming ability. But it was fun to attempt.
The result of all this; in my opinion; is a joystick or push button interface is a better control mechanism. So I have ordered a Kitronik Game control board to experiment further with the micro:Bit.