Skip to content

Instantly share code, notes, and snippets.

@fisherds
Created May 4, 2021 16:53
Show Gist options
  • Save fisherds/2d8632142403ef6aaeb6258960bbf076 to your computer and use it in GitHub Desktop.
Save fisherds/2d8632142403ef6aaeb6258960bbf076 to your computer and use it in GitHub Desktop.
Helper program I used to work out the details for my sensor methods
"""
Authors: Dave Fisher and PUT_YOUR_NAME_HERE.
"""
# TODO: 1. Put your name in the above.
import time
import rosebot
def main():
print()
print(" Ultrasonic (cm) Line Sensors: Left Middle Right")
print("----------------- ----- ----- -----")
robot = rosebot.RoseBot()
while True:
print(" {:5.1f} {} {} {}".format(
robot.ultrasonic.get_distance(),
"W" if robot.line_sensors.get_left_value() == 0 else "B",
"W" if robot.line_sensors.get_middle_value() == 0 else "B",
"W" if robot.line_sensors.get_right_value() == 0 else "B"))
time.sleep(1)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment