Programas de ejemplo
En el repositorio 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
Sensor name | Part name | Test program name |
---|---|---|
RGB Color detection | APDS 9660 | read_color_sensor.py |
ToF 8x8 Array - up to 350 cm | LSM6DSOX | read_tof.py |
IMU - 6 degree | VL53L7CX | read_imu.py |
3x Line follower | custom made | line_follower.py |
7x Touch sensor | AT42QT2120 | read_touch.py |
Actuator name | Part name | Test program name |
Geared motors w/ encoder | GM12-N20VA-08255-150-EN | wheels_positions.py |
RGB LEDs | RGB LEDs | leds_settings.py |
Detector de color
Modificación del read_color_sensor.py
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()