... | ... | @@ -90,14 +90,14 @@ You can check to make sure that you have the library by searching for the librar |
|
|
|
|
|
<details>
|
|
|
<summary>
|
|
|
Potential Python Solution (Click to Expand)
|
|
|
Potential Python Edit controller.py(Click to Expand)
|
|
|
</summary>
|
|
|
<pre>
|
|
|
from microbit import *
|
|
|
import radio
|
|
|
|
|
|
radio_group = 0 #number of radio frequency to use
|
|
|
forward = False
|
|
|
reverse = False #Changed forward var to reverse
|
|
|
group_set = False #has the radio group been set?
|
|
|
radio.on()
|
|
|
radio.config(power=7)
|
... | ... | @@ -119,10 +119,10 @@ while True:# do forever |
|
|
display.show(Image.HAPPY)
|
|
|
forward = False
|
|
|
else:
|
|
|
if reverse == False:
|
|
|
radio.send("reverse")
|
|
|
reverse = True
|
|
|
display.show(Image.ARROW_S)
|
|
|
if reverse == False: #changed forward to reverse
|
|
|
radio.send("reverse") #changed forward to reverse
|
|
|
reverse = True #changed forward to reverse
|
|
|
display.show(Image.ARROW_S) #Display a down arrow instead of up
|
|
|
else:
|
|
|
radio.send("stop")
|
|
|
forward = False
|
... | ... | @@ -145,10 +145,56 @@ while True:# do forever |
|
|
</pre>
|
|
|
</details>
|
|
|
|
|
|
<details>
|
|
|
<summary>
|
|
|
Potential Python Edit, Excerpt from robot.py(Click to Expand)
|
|
|
</summary>
|
|
|
<pre>
|
|
|
while True:# do forever
|
|
|
if not group_set:
|
|
|
display.show(str(radio_group))
|
|
|
if button_a.is_pressed() and button_b.is_pressed():
|
|
|
group_set = True
|
|
|
radio.config(channel = radio_group)
|
|
|
display.show(Image.HAPPY)
|
|
|
|
|
|
elif button_a.is_pressed():
|
|
|
if radio_group > 0:
|
|
|
radio_group = radio_group - 1
|
|
|
|
|
|
elif button_b.is_pressed():
|
|
|
if radio_group < 255:
|
|
|
radio_group = radio_group + 1
|
|
|
sleep(150)
|
|
|
|
|
|
else:# radio group has been set
|
|
|
incoming = radio.receive()
|
|
|
|
|
|
if incoming is "reverse": #changed forward to reverse
|
|
|
motobit.drive(-127, -127) #drive the motors backward instead of forward
|
|
|
display.show(Image.ARROW_N)
|
|
|
sleep(200)
|
|
|
motobit.drive(0,0)
|
|
|
elif incoming is "right":
|
|
|
motobit.drive(60,-60)
|
|
|
display.show(Image.ARROW_E)
|
|
|
sleep(200)
|
|
|
motobit.drive(0,0)
|
|
|
elif incoming is "left":
|
|
|
motobit.drive(-60, 60)
|
|
|
display.show(Image.ARROW_W)
|
|
|
sleep(200)
|
|
|
motobit.drive(0,0)
|
|
|
sleep(100)
|
|
|
</pre>
|
|
|
</details>
|
|
|
|
|
|
|
|
|
<br></br>
|
|
|
* Are you able to control another group's robot?
|
|
|
* Does your control work with their robot?
|
|
|
* How about after you play with the code?
|
|
|
|
|
|
---
|
|
|
>>>
|
|
|
The GenCyber Wyoming COWPOKES program is supported by the National Security Agency and the National Science Foundation through Award #H98230-18-1-0095. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation, the National Security Agency, or the U.S. government.
|
... | ... | |