Zumo 32u4 compass

I use zumo 32u4 .when i use command compass.read my robot is hanged. it can not do any thing what happend . How to fix it

how to reset the value of encodert.

Hello, Alongkorn.

I am sorry you are having trouble getting your Zumo 32U4’s compass working. I merged your two threads, since your other question is also related to coding a Zumo 32U4.

It is not clear what sketch you were running that used compass.read(). If it was your own script, I could help you narrow down where the issue is. But first, can you try running our example sketch, InertialSensors.ino, and let me know how that goes? You can find that example in the Zumo 32U4 Arduino library, which you can find a link to the GitHub page for under the Resources tab of the Zumo 32U4’s product page.

To reset the encoder counts, you can use either getCountsAndResetLeft() or getCountsAndResetRight(). More information on those commands can be found in the Zumo32U4 library documentation.


Hello jonathanKosh
I have run sketch inertialSensors.ino already. I have not problem. when I turn my robot
to any direction .it have many data change on monitor page.

but when i insert some code from the sketch inertialSensors.ino and try to upload to my robot
my robot was hanged.

how to fix it

I do not see anything obviously wrong with the compass related commands you are showing in the last picture of your post, with the image of a section of your sketch. It looks like your code is quite long. In general, a useful approach to troubleshooting code is to start simple with a known working set of code and incrementally add modifications. So, I recommend starting with our InertialSensors.ino sketch and modifying it until you have created the compass code you want your Zumo to have, and then adding that code back in to your main sketch. If you still have a problem after trying an approach like that, can you simplify your sketch to the simplest version that should work but does not, and then post the full sketch and the full serial output you get from the sketch?