- #!/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()
- eye = UltrasonicSensor(Port.S4)
- left_motor = Motor(Port.B)
- right_motor = Motor(Port.C)
- gun = Motor(Port.A)
- # Write your program here.
- while True:
- if eye.distance() <= 700:
- #left_motor.run_time(-50, 1000, Stop.HOLD, True)
- #right_motor.run_time(50, 1000, Stop.HOLD, True)
- gun.run_time(800, 500, Stop.HOLD, True)
- gun.run_time(-800, 500, Stop.HOLD, True)
- while not ev3.buttons.pressed():
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
You can edit this paste and save as new: