Front and Back Bumpers, Sensors and LEDs - Paladins-of-St-Pauls/StudentRobotics GitHub Wiki
You can test if the front or back bumpers are pressed:
def front_bumper():
return R.ruggeduinos[0].digital_read(2)
def back_bumper():
return R.ruggeduinos[0].digital_read(3)
You can turn LEDs on/off
from enum import IntEnum
class LED(IntEnum):
RIGHT_RED = 4
RIGHT_GREEN = 5
RIGHT_BLUE = 6
LEFT_BLUE = 7
LEFT_GREEN = 8
LEFT_RED = 9
def led(led_enum, state):
R.ruggeduinos[0].digital_write(led_enum, state)
led(LED.LEFT_BLUE,True)
led(LED.LEFT_BLUE,False)
You can get distances:
class SENSOR(IntEnum):
FRONT_LEFT = 0
FRONT_RIGHT = 1
LEFT = 2
RIGHT = 3
BACK_LEFT = 4
BACK_RIGHT = 5
def distance(sensor_enum):
return R.ruggeduinos[0].analogue_read(sensor_enum)
print(f"Distance[L,R] = {distance(SENSOR.FRONT_LEFT)}, {distance(SENSOR.FRONT_RIGHT)}")