I’ve built a working digital compass that lights up one of 8 LEDs that is positioned closest to North as the device is rotated. Since I’m a complete beginner I had to utilize a good bit of code I don’t understand to interpret the data my HCM5883L magnometer sends to the Arduino. What I need to do however, is to mount the magnometer board vertically instead of horizontally as it currently is on my breadboard.
I’ve tried editing the code and just swapping the X and Z axises then recalibrating, but that doesn’t seem to have done it. I took on a pretty complex project for my very first project and am surprised I’ve made it this far, but if someone can help me with this last bit I can call this project done! Suggestions? I’ve attached my sketch. Thank you so much!!
compass.cpp (12.9 KB)
compass.h (753 Bytes)
digital_compass_latest.ino (5.76 KB)