Hovercraft v1. /JL
This commit is contained in:
35
avanceret/hovercraft/controller/main.py
Normal file
35
avanceret/hovercraft/controller/main.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
'''
|
||||||
|
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()
|
||||||
|
|
||||||
|
def move_forward():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def move_back():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def turn_right():
|
||||||
|
pass
|
||||||
|
|
||||||
|
def turn_left():
|
||||||
|
pass
|
||||||
|
|
||||||
|
while True:
|
||||||
|
command = radio.receive()
|
||||||
|
if command == "forward":
|
||||||
|
move_forward()
|
||||||
|
elif command == "back":
|
||||||
|
move_back()
|
||||||
|
elif command == "right":
|
||||||
|
turn_right()
|
||||||
|
elif command == "left":
|
||||||
|
turn_left()
|
||||||
22
avanceret/hovercraft/remote/main.py
Normal file
22
avanceret/hovercraft/remote/main.py
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
'''
|
||||||
|
This is code for the hovercraft remote
|
||||||
|
'''
|
||||||
|
from microbit import *
|
||||||
|
|
||||||
|
# We start by initiating radio communication
|
||||||
|
# We want a strong signal
|
||||||
|
|
||||||
|
import radio
|
||||||
|
|
||||||
|
radio.config(group=99, power=7)
|
||||||
|
radio.on()
|
||||||
|
|
||||||
|
while True:
|
||||||
|
if accelerometer.was_gesture("down"):
|
||||||
|
radio.send("forward")
|
||||||
|
if accelerometer.was_gesture("up"):
|
||||||
|
radio.send("back")
|
||||||
|
if accelerometer.was_gesture("left"):
|
||||||
|
radio.send("left")
|
||||||
|
if accelerometer.was_gesture("right"):
|
||||||
|
radio,send("right")
|
||||||
Reference in New Issue
Block a user