Programas de test
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()
Detector TOF
Si ejecutamos read_tof.py
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
Giro
Si ejecutamos read_imu.py
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
No Comments