Skip to content

Instantly share code, notes, and snippets.

@KitWallace
Created September 22, 2012 11:37
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KitWallace/3765893 to your computer and use it in GitHub Desktop.
Save KitWallace/3765893 to your computer and use it in GitHub Desktop.
Compass with declination correction
#!/usr/bin/python
import time
from Devantech_CMPS10 import CMPS10
compass = CMPS10()
declination = -2.2148
while True :
magnetic_bearing= compass.bearing()
true_bearing = round((magnetic_bearing + declination) % 360,1)
print str(magnetic_bearing)+"M", str(true_bearing)+"T"
time.sleep(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment