'{$STAMP BS2} '*********************************************************** '** ** '** PWM Routines for the Basic Stamp ** '** using the CMPS01 Compass Module ** '** ** '** Copyright 2002 - Devantech Ltd ** '** Commercial use of this software is prohibited ** '** Private and educational use only is permitted ** '** ** '** Written by Gerald Coe - January 2002 ** '** ** '** This Code has been Tested on BS2 and BS2p ** '** It should work equally well on the BS2e and BS2sx ** '** ** '*********************************************************** bearing var word main: pulsin 8, 1, bearing ' Get reading bearing = (bearing-500)/50 ' BS2(e) - Calculate Bearing in degrees ' bearing = (bearing-1250)/125 ' BS2sx - Calculate Bearing in degrees ' bearing = (bearing-1333)/133 ' BS2p - Calculate Bearing in degrees debug 2,1,1, "Compass Bearing ", dec3 bearing ' Display Compass Bearing goto main ' around forever