from machine import ADC from time import sleep_ms a2d0 = ADC(0) a2d1 = ADC(1) a2d2 = ADC(2) def Read_ADXL335(): k = 200 / 65535 x1 = a2d0.read_u16() y1 = a2d1.read_u16() z1 = a2d2.read_u16() Ax = k * (x1 - 13843) Ay = k * (y1 - 13779) Az = k * (z1 - 13843) - 3.6 return([Ax, Ay, Az]) while(1): [Ax, Ay, Az] = Read_ADXL335() Acc = (Ax**2 + Ay**2 + Az**2) ** 0.5 print('{: 10.3f}'.format(Ax), '{: 10.3f}'.format(Ay), '{: 10.3f}'.format(Az), '{: 10.3f}'.format(Acc)) sleep_ms(200)