Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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
- # This program requires LEGO EV3 MicroPython v2.0 or higher.
- # Click "Open user guide" on the EV3 extension tab for more information.
- # Create your objects here.
- ev3 = EV3Brick()
- left_motor = Motor(Port.C)
- right_motor = Motor(Port.B)
- color = DriveBase(left_motor, right_motor, wheel_diameter=57.15, axle_track=88.9)
- pause=1000
- # wait is in MS
- # I made a function because I didn't wanna change all the waits. I am very lazy.
- while True:
- ev3.light.on(Color.RED)
- wait(pause)
- ev3.light.on(Color.ORANGE)
- wait(pause)
- ev3.light.on(Color.GREEN)
- wait(pause)
- ev3.light.on(Color.YELLOW)
- wait(pause)
- ev3.speaker.beep
- # I was trying to do R,B,G but Blue is apparently invalid! It doesn't display any color, which is labeled as a incorrect value in the documents
- # Apparently Red/Orange/Green are the only values allowed in the MINDSTORMs program, but Yellow works perfectly fine.
- # Setting pause to 0 is probably an epilepsy inducer and it hurts my eyes. 0/10 would not recommend
- # Having no waits inbetween will cause it to remain on the last color (its too fast)
- # Indents are required. Only indented stuff below a loop will be looped. Tripped me up because C++ needs parentheses.
Advertisement