Updated. /JL
This commit is contained in:
@@ -11,29 +11,35 @@ import radio
|
||||
radio.config(group=99, power=7)
|
||||
radio.on()
|
||||
|
||||
flying = False
|
||||
A = 0 #Arm
|
||||
R = 0 #Roll
|
||||
T = 0 #Throttle
|
||||
|
||||
def take_of():
|
||||
flying = True
|
||||
radio.sendValue("takeof", flying)
|
||||
A = 1
|
||||
radio.sendValue("A", A)
|
||||
|
||||
def land():
|
||||
flying = False
|
||||
radio.sendValue("land", flying)
|
||||
A = 0
|
||||
radio.sendValue("A", A)
|
||||
|
||||
while True:
|
||||
if flying == True:
|
||||
if A == 1:
|
||||
if accelerometer.was_gesture("down"):
|
||||
radio.send("forward")
|
||||
T += 0.1
|
||||
radio.sendValue("T", T)
|
||||
if accelerometer.was_gesture("up"):
|
||||
radio.send("back")
|
||||
T -= 0.1
|
||||
radio.sendValue("T", T)
|
||||
if accelerometer.was_gesture("left"):
|
||||
radio.send("left")
|
||||
R += 45
|
||||
radio.sendValue("R", R)
|
||||
if accelerometer.was_gesture("right"):
|
||||
radio.send("right")
|
||||
if button_a.was_pressed():
|
||||
if flying != True:
|
||||
R -= 45
|
||||
radio.sendValue("R", R)
|
||||
if button_b.was_pressed():
|
||||
land()
|
||||
else:
|
||||
if button_a.was_pressed():
|
||||
take_of()
|
||||
if button_b.was_pressed():
|
||||
if flying != False:
|
||||
land()
|
||||
T, R = 0, 0
|
||||
Reference in New Issue
Block a user