Update. /JL
This commit is contained in:
@@ -11,11 +11,18 @@ import radio
|
|||||||
radio.config(group=99, power=7)
|
radio.config(group=99, power=7)
|
||||||
radio.on()
|
radio.on()
|
||||||
|
|
||||||
|
throttle = 0
|
||||||
|
flying = False
|
||||||
|
|
||||||
def move_forward():
|
def move_forward():
|
||||||
pass
|
throttle += 50
|
||||||
|
if throttle > 100:
|
||||||
|
throttle = 100
|
||||||
|
|
||||||
def move_back():
|
def move_back():
|
||||||
pass
|
throttle -= 50
|
||||||
|
if throttle < 0:
|
||||||
|
throttle = 0
|
||||||
|
|
||||||
def turn_right():
|
def turn_right():
|
||||||
pass
|
pass
|
||||||
@@ -23,13 +30,29 @@ def turn_right():
|
|||||||
def turn_left():
|
def turn_left():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def take_of():
|
||||||
|
#switch hover motor on
|
||||||
|
flying = True
|
||||||
|
pass
|
||||||
|
|
||||||
|
def land():
|
||||||
|
#switch hover motor off
|
||||||
|
flying = False
|
||||||
|
pass
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
command = radio.receive()
|
Arm = radio.receiveValue("A")
|
||||||
if command == "forward":
|
if flying == True:
|
||||||
move_forward()
|
if command == "forward":
|
||||||
elif command == "back":
|
move_forward()
|
||||||
move_back()
|
elif command == "back":
|
||||||
elif command == "right":
|
move_back()
|
||||||
turn_right()
|
elif command == "right":
|
||||||
elif command == "left":
|
turn_right()
|
||||||
turn_left()
|
elif command == "left":
|
||||||
|
turn_left()
|
||||||
|
elif command == "land":
|
||||||
|
land()
|
||||||
|
else:
|
||||||
|
if command == ("take_of"):
|
||||||
|
take_of()
|
||||||
|
|||||||
@@ -11,12 +11,29 @@ import radio
|
|||||||
radio.config(group=99, power=7)
|
radio.config(group=99, power=7)
|
||||||
radio.on()
|
radio.on()
|
||||||
|
|
||||||
|
flying = False
|
||||||
|
|
||||||
|
def take_of():
|
||||||
|
flying = True
|
||||||
|
radio.sendValue("takeof", flying)
|
||||||
|
|
||||||
|
def land():
|
||||||
|
flying = False
|
||||||
|
radio.sendValue("land", flying)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if accelerometer.was_gesture("down"):
|
if flying == True:
|
||||||
radio.send("forward")
|
if accelerometer.was_gesture("down"):
|
||||||
if accelerometer.was_gesture("up"):
|
radio.send("forward")
|
||||||
radio.send("back")
|
if accelerometer.was_gesture("up"):
|
||||||
if accelerometer.was_gesture("left"):
|
radio.send("back")
|
||||||
radio.send("left")
|
if accelerometer.was_gesture("left"):
|
||||||
if accelerometer.was_gesture("right"):
|
radio.send("left")
|
||||||
radio,send("right")
|
if accelerometer.was_gesture("right"):
|
||||||
|
radio.send("right")
|
||||||
|
if button_a.was_pressed():
|
||||||
|
if flying != True:
|
||||||
|
take_of()
|
||||||
|
if button_b.was_pressed():
|
||||||
|
if flying != False:
|
||||||
|
land()
|
||||||
Reference in New Issue
Block a user