SHOW:
|
|
- or go back to the newest paste.
| 1 | #!/usr/bin/env pybricks-micropython | |
| 2 | from pybricks.hubs import EV3Brick | |
| 3 | from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, | |
| 4 | InfraredSensor, UltrasonicSensor, GyroSensor) | |
| 5 | from pybricks.parameters import Port, Stop, Direction, Button, Color | |
| 6 | from pybricks.tools import wait, StopWatch, DataLog | |
| 7 | from pybricks.robotics import DriveBase | |
| 8 | from pybricks.media.ev3dev import SoundFile, ImageFile | |
| 9 | ||
| 10 | ||
| 11 | # This program requires LEGO EV3 MicroPython v2.0 or higher. | |
| 12 | # Click "Open user guide" on the EV3 extension tab for more information. | |
| 13 | ||
| 14 | ||
| 15 | # Create your objects here. | |
| 16 | ev3 = EV3Brick() | |
| 17 | left_motor = Motor(Port.C) | |
| 18 | right_motor = Motor(Port.B) | |
| 19 | color = DriveBase(left_motor, right_motor, wheel_diameter=57.15, axle_track=88.9) | |
| 20 | pause=1000 | |
| 21 | # wait is in MS | |
| 22 | # I made a function because I didn't wanna change all the waits. I am very lazy. | |
| 23 | ||
| 24 | while True: | |
| 25 | ev3.light.on(Color.RED) | |
| 26 | wait(pause) | |
| 27 | ev3.light.on(Color.ORANGE) | |
| 28 | wait(pause) | |
| 29 | ev3.light.on(Color.GREEN) | |
| 30 | wait(pause) | |
| 31 | ev3.light.on(Color.YELLOW) | |
| 32 | wait(pause) | |
| 33 | ev3.speaker.beep | |
| 34 | # 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 | |
| 35 | # Apparently Red/Orange/Green are the only values allowed in the MINDSTORMs program, but Yellow works perfectly fine. | |
| 36 | # Setting pause to 0 is probably an epilepsy inducer and it hurts my eyes. 0/10 would not recommend | |
| 37 | # Having no waits inbetween will cause it to remain on the last color (its too fast) | |
| 38 | # Indents are required. Only indented stuff below a loop will be looped. Tripped me up because C++ needs parentheses. |