Update. /JL

This commit is contained in:
2025-09-15 11:40:41 +02:00
parent 489d40f8fc
commit e98da9b6fd
2 changed files with 59 additions and 19 deletions

View File

@@ -11,11 +11,18 @@ import radio
radio.config(group=99, power=7)
radio.on()
throttle = 0
flying = False
def move_forward():
pass
throttle += 50
if throttle > 100:
throttle = 100
def move_back():
pass
throttle -= 50
if throttle < 0:
throttle = 0
def turn_right():
pass
@@ -23,8 +30,19 @@ def turn_right():
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:
command = radio.receive()
Arm = radio.receiveValue("A")
if flying == True:
if command == "forward":
move_forward()
elif command == "back":
@@ -33,3 +51,8 @@ while True:
turn_right()
elif command == "left":
turn_left()
elif command == "land":
land()
else:
if command == ("take_of"):
take_of()

View File

@@ -11,7 +11,18 @@ import radio
radio.config(group=99, power=7)
radio.on()
flying = False
def take_of():
flying = True
radio.sendValue("takeof", flying)
def land():
flying = False
radio.sendValue("land", flying)
while True:
if flying == True:
if accelerometer.was_gesture("down"):
radio.send("forward")
if accelerometer.was_gesture("up"):
@@ -19,4 +30,10 @@ while True:
if accelerometer.was_gesture("left"):
radio.send("left")
if accelerometer.was_gesture("right"):
radio,send("right")
radio.send("right")
if button_a.was_pressed():
if flying != True:
take_of()
if button_b.was_pressed():
if flying != False:
land()