code for a digital compass for a uni project