# Sensores de movimiento

##### <span style="color: rgb(22, 145, 121);">**Sensor agitación**</span>

```
import cyberpi

cyberpi.display.show_label("Shake Value\nA:Start",16,0,0,0)

while not cyberpi.controller.is_press('a'):
    pass

while True:
    shake_value = cyberpi.get_shakeval()
    cyberpi.display.show_label("Shake Value",16,20,0,0)
    cyberpi.display.show_label("{}%".format(shake_value),24,40,50,1)
```

{{@13396#bkmrk-extraido-de-https%3A%2F%2F}}

<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" frameborder="0" height="635" src="https://www.youtube.com/embed/bTmeeCBABAA" title="Sensor agitación mbot2 python" width="357"></iframe>

##### <span style="color: rgb(22, 145, 121);">**Inclinación y rotación**</span>

El siguiente programa enseña los dos ángulos de inclinación en eje X e Y y rotación en eje Z

```python
import cyberpi

cyberpi.display.show_label("YAW PITCH ROLL\nA:Start",16,0,0,0)

while not cyberpi.controller.is_press('a'):
    pass
while True:
    pitch = cyberpi.get_pitch()
    roll = cyberpi.get_roll()
    yaw = cyberpi.get_yaw()

    cyberpi.display.show_label("Yaw\n\nPitch\n\nRoll\n\n",16,0,0,0)
    cyberpi.display.show_label("{}\n\n{}\n\n{}".format(pitch,roll,yaw),16,50,0,1)
```

{{@13396#bkmrk-extraido-de-https%3A%2F%2F}}

El resultado es muy parecido con la función de gyro

```python
import cyberpi

cyberpi.reset_rotation(axis='all')
cyberpi.display.show_label("Gyroscope\nA:Start",16,0,0,0)

while not cyberpi.controller.is_press('a'):
    pass
    
while True:
    x_gyro = cyberpi.get_gyro('x')
    y_gyro = cyberpi.get_gyro('y')
    z_gyro = cyberpi.get_gyro('z')

    cyberpi.display.show_label("X\n\nY\n\nZ\n\n",16,0,0,0)
    cyberpi.display.show_label("{}\n\n{}\n\n{}".format(x_gyro,y_gyro,z_gyro),16,50,0,1)
```

{{@13396#bkmrk-extraido-de-https%3A%2F%2F}}

Y rotation

```python
import cyberpi

cyberpi.reset_rotation(axis='all')
cyberpi.display.show_label("Rotation\nA:Start",16,0,0,0)

while not cyberpi.controller.is_press('a'):
    pass
    
while True:
    x_rotate = cyberpi.get_rotation('x')
    y_rotate = cyberpi.get_rotation('y')
    z_rotate = cyberpi.get_rotation('z')

    cyberpi.display.show_label("X\n\nY\n\nZ\n\n",16,0,0,0)
    cyberpi.display.show_label("{}\n\n{}\n\n{}".format(x_rotate,y_rotate,z_rotate),16,50,0,1)
```

{{@13396#bkmrk-extraido-de-https%3A%2F%2F}}

<iframe allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen="allowfullscreen" frameborder="0" height="635" src="https://www.youtube.com/embed/i3HnE8lIdLo" title="Inclinación y rotación mbot2 python" width="357"></iframe>