# Programas de test

En el repositorio [https://github.com/arduino/arduino-alvik-mpy/tree/main/examples](https://github.com/arduino/arduino-alvik-mpy/tree/main/examples) podemos encontrar ejemplos para ver el uso de los diferentes sensores y actuadores, por ejemplo

<table id="bkmrk-sensor-name-part-nam"><thead><tr><th>**Sensor name**</th><th>**Part name**</th><th>**Test program name**</th></tr></thead><tbody><tr><td>RGB Color detection</td><td>APDS 9660</td><td>read\_color\_sensor.py</td></tr><tr><td>ToF 8x8 Array - up to 350 cm</td><td>LSM6DSOX</td><td>read\_tof.py</td></tr><tr><td>IMU - 6 degree</td><td>VL53L7CX</td><td>read\_imu.py</td></tr><tr><td>3x Line follower</td><td>custom made</td><td>line\_follower.py</td></tr><tr><td>7x Touch sensor</td><td>AT42QT2120</td><td>read\_touch.py</td></tr><tr><th>**Actuator name**</th><th>**Part name**</th><th>**Test program name**</th></tr><tr><td>Geared motors w/ encoder</td><td>GM12-N20VA-08255-150-EN</td><td>wheels\_positions.py</td></tr><tr><td>RGB LEDs</td><td>RGB LEDs</td><td>leds\_settings.py</td></tr></tbody></table>

##### <span style="color: rgb(22, 145, 121);">**Detector de color**</span>

Modificación del read\_color\_sensor.py

```python
from arduino_alvik import ArduinoAlvik
from time import sleep_ms
import sys

alvik = ArduinoAlvik()
alvik.begin()

while True:
    try:
        r, g, b = alvik.get_color()
        h, s, v = alvik.get_color('hsv')
        print(f'RED: {r}, Green: {g}, Blue: {b}, HUE: {h}, SAT: {s}, VAL: {v}')
        print(f'COLOR LABEL:')
        print ({alvik.get_color_label()})
        sleep_ms(1000)
    except KeyboardInterrupt as e:
        print('over')
        alvik.stop()
        sys.exit()
```

<iframe allowfullscreen="allowfullscreen" height="314" src="https://www.youtube.com/embed/j0tgpjJKK40" width="560"></iframe>

##### <span style="color: rgb(22, 145, 121);">**Detector TOF**</span>

Si ejecutamos read\_tof.py

```python
from arduino_alvik import ArduinoAlvik
from time import sleep_ms
import sys

alvik = ArduinoAlvik()
alvik.begin()

while True:
    try:
        L, CL, C, CR, R = alvik.get_distance()
        T = alvik.get_distance_top()
        B = alvik.get_distance_bottom()
        print(f'T: {T} | B: {B} | L: {L} | CL: {CL} | C: {C} | CR: {CR} | R: {R}')
        sleep_ms(100)
    except KeyboardInterrupt as e:
        print('over')
        alvik.stop()
        sys.exit()

```

Detecta hasta los obstáculos por arriba

<iframe allowfullscreen="allowfullscreen" height="314" src="https://www.youtube.com/embed/XHXCfblL4ks" width="560"></iframe>

##### <span style="color: rgb(22, 145, 121);">**Giro**</span>

Si ejecutamos read\_imu.py

```python
from arduino_alvik import ArduinoAlvik
from time import sleep_ms
import sys

alvik = ArduinoAlvik()
alvik.begin()

while True:
    try:
        ax, ay, az = alvik.get_accelerations()
        gx, gy, gz = alvik.get_gyros()
        print(f'ax: {ax}, ay: {ay}, az: {az}, gx: {gx}, gy: {gy}, gz: {gz}')
        sleep_ms(100)
    except KeyboardInterrupt as e:
        print('over')
        alvik.stop()
        sys.exit()
```

Vemos como el eje x cambia de -1 0 a 1 según la posición

<iframe allowfullscreen="allowfullscreen" height="314" src="https://www.youtube.com/embed/E083Xe_IMFY" width="560"></iframe>