Files
python-microbit/avanceret/hovercraft/controller/main.py
2025-09-15 11:40:41 +02:00

59 lines
1018 B
Python

'''
This is code for the hovercraft onboard controller
'''
from microbit import *
# We start by initiating radio communication
# We want a strong signal
import radio
radio.config(group=99, power=7)
radio.on()
throttle = 0
flying = False
def move_forward():
throttle += 50
if throttle > 100:
throttle = 100
def move_back():
throttle -= 50
if throttle < 0:
throttle = 0
def turn_right():
pass
def turn_left():
pass
def take_of():
#switch hover motor on
flying = True
pass
def land():
#switch hover motor off
flying = False
pass
while True:
Arm = radio.receiveValue("A")
if flying == True:
if command == "forward":
move_forward()
elif command == "back":
move_back()
elif command == "right":
turn_right()
elif command == "left":
turn_left()
elif command == "land":
land()
else:
if command == ("take_of"):
take_of()