#!/usr/bin/env pybricks-micropython from pybricks import ev3brick as brick from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, InfraredSensor, UltrasonicSensor, GyroSensor) from pybricks.parameters import (Port, Stop, Direction, Button, Color, SoundFile, ImageFile, Align) from pybricks.tools import print, wait, StopWatch from pybricks.robotics import DriveBase # Write your program here brick.sound.file(SoundFile.FANFARE, volume=100) brick.display.image(ImageFile.ANGRY) motorA = Motor(Port.A) motorD = Motor(Port.D) colorSense = ColorSensor(Port.S1) distSense = UltrasonicSensor(Port.S3) while not any(brick.buttons()): pass motorA.run(5000) motorD.run(5000) colorVal = colorSense.color() distVal = distSense.distance() brick.light(Color.GREEN) if colorVal == None: motorA.run(-5000) motorD.run(-5000) wait(1200) motorA.run(-5000) motorD.run(5000) wait(2000) if distVal <= 120: brick.light(Color.RED) motorA.run(-5000) motorD.run(5000) wait(500) brick.sound.file(SoundFile.T_REX_ROAR, volume=100)