#!/usr/bin/env pybricks-micropython from pybricks.hubs import EV3Brick from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, InfraredSensor, UltrasonicSensor, GyroSensor) from pybricks.parameters import Port, Stop, Direction, Button, Color from pybricks.tools import wait, StopWatch, DataLog from pybricks.robotics import DriveBase from pybricks.media.ev3dev import SoundFile, ImageFile # Create your objects here. ev3 = EV3Brick() # Initialize the motors. left_motor = Motor(Port.B) right_motor = Motor(Port.C) # Initialize the drive base. #robot = DriveBase(left_motor, right_motor, wheel_diameter=56, axle_track=114) robot = DriveBase(left_motor, right_motor, wheel_diameter=41, axle_track=106) #Initialize the color sensor color_sensor = ColorSensor(Port.S1) while True: if color_sensor.color() == Color.RED: ev3.speaker.say("red") elif color_sensor.color() == Color.BLUE: ev3.speaker.say("blue") elif color_sensor.color() == Color.YELLOW: ev3.speaker.say("yellow") elif color_sensor.color() == Color.BLACK: ev3.speaker.say("black") elif color_sensor.color() == Color.GREEN: ev3.speaker.say("green") elif color_sensor.color() == Color.WHITE: ev3.speaker.say("white") else: ev3.speaker.say("unknown") # ev3.screen.print(color_sensor.reflection()) wait(1000)