Example Code for Micropython-Read Accelerated Velocity
Last revision 2026/01/15
In this section, we will teach you how to read the correct accelerated velocity. (Sample: SEN0178)
Sample Code
from machine import ADC,Pin
import time
X=0.774
gx=0.237
Y=0.781
gy=0.21
Z=0.923
gz=0.235
x_adc=ADC(Pin(36))
y_adc=ADC(Pin(39))
z_adc=ADC(Pin(34))
while True:
x=x_adc.read()
y=y_adc.read()
z=z_adc.read()
print("x=",(x*5/1024.0 - X)/gx)
print("y=",(y*5/1024.0 - Y)/gy)
print("z=",(z*5/1024.0 - Z)/gz)
time.sleep_ms(50)
Was this article helpful?
