Herunterladen Diese Seite drucken

Arduino Alvik Bedienungsanleitung Seite 52

Werbung

user-manual-de.md
from
arduino_alvik
import
network
import
espnow
# Initialize ESP-NOW
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
esp = espnow.ESPNow()
esp.active(True)
# Print the MAC address
mac = wlan.config('mac')
print("MAC
address:",
# Initialize Alvik
alvik = ArduinoAlvik()
alvik.begin()
def
perform_action(command):
print(f"Performing action:
if
command == "MOVE_FORWARD":
alvik.set_wheels_speed(60, 60)
elif
command == "MOVE_BACKWARD":
alvik.set_wheels_speed(-60, -60)
elif
command == "TURN_LEFT":
alvik.set_wheels_speed(-60, 60)
elif
command == "TURN_RIGHT":
alvik.set_wheels_speed(60, -60)
elif
command == "STOP":
alvik.brake()
elif
command == "ACTION":
pass
print("Waiting for
while
True:
try:
host, msg = esp.recv()
if
msg:
print(f"Received message from {host}:
perform_action(msg.decode())
else:
print("No message
except
Exception
print(f"An error occurred:
except
KeyboardInterrupt:
alvik.stop()
print("Script terminated by
sys.exit()
Einrichten von ESP-NOW auf dem Sender
import
ArduinoAlvik
':'.join('%02x'
{command}")
commands...")
received")
as
e:
{e}")
user")
% b
for
b
in
mac))
{msg}")
52 / 70
2024-11-14

Werbung

loading

Diese Anleitung auch für:

Akx00066