# Convert the data xAccl = (data[1] * 256 + data[2]) / 16 if xAccl > 2047: xAccl -= 4096 yAccl = (data[3] * 256 + data[4]) / 16 if yAccl > 2047: yAccl -= 4096 zAccl = (data[5] * 256 + data[6]) / 16 if zAccl > 2047: zAccl -= 4096 return {'x': xAccl, 'y': yAccl, 'z': zAccl} from MMA8452Q import MMA8452Q mma8452q = MMA8452Q() while True: mma8452q.mode_configuration() mma8452q.data_configuration() time.sleep(0.5) accl = mma8452q.read_accl() print "Acceleration in X-Axis : %d" % (accl['x']) print "Acceleration in Y-Axis : %d" % (accl['y']) print "Acceleration in Z-Axis : %d" % (accl['z']) print " ************************************* " time.sleep(0.5)
#Change the System Time to Test. #os.system('sudo date --s="2018-05-27 19:59:00"') #---setup---- ''' #if you want to use serial. #Windows ser=serial.Serial("COM1",2400,timeout=0.5) #Linux ser=serial.Serial("/dev/ttyUSB0",2400,timeout=0.5) ''' azimuth = HMC5883L() elevation = MMA8452Q() Tracker = Tracker("/dev/ttyUSB0", 2400) #Tracker = Tracker("COM1") #----------------Big Loop---------------- def goto(az, el): AZ_now = azimuth.read() #azimuth EL_now = elevation.read() #elevation time.sleep(0.5) def track(satname):