-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pybricks.pupdevices.Remote: Add more examples.
- Loading branch information
1 parent
8463206
commit 62bb262
Showing
5 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from pybricks.pupdevices import Remote | ||
|
||
# Connect to any remote. | ||
my_remote = Remote() | ||
|
||
# Print the current name of the remote. | ||
print(my_remote.name()) | ||
|
||
# Choose a new name. | ||
my_remote.name('truck2') | ||
|
||
print("Done!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from pybricks.pupdevices import Remote | ||
|
||
try: | ||
# Search for a remote for 5 seconds. | ||
my_remote = Remote(timeout=5000) | ||
|
||
print("Connected!") | ||
|
||
# Here you can write code that uses the remote. | ||
|
||
except OSError: | ||
|
||
print("Could not find the remote.") | ||
|
||
# Here you can make your robot do something | ||
# without the remote. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from pybricks.pupdevices import Remote | ||
|
||
# Connect to any remote. Search forever until we find one. | ||
my_remote = Remote(timeout=None) | ||
|
||
print("Connected!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from pybricks.pupdevices import Remote | ||
from pybricks.tools import wait | ||
|
||
# Connect to a remote called truck2. | ||
truck_remote = Remote('truck2', timeout=None) | ||
|
||
print("Connected!") | ||
|
||
wait(2000) |