-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain01.py
More file actions
33 lines (25 loc) · 995 Bytes
/
main01.py
File metadata and controls
33 lines (25 loc) · 995 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/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
import time
# 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.B)
right_motor = Motor(Port.D)
servo = Motor(Port.C)
gyro = GyroSensor(Port.S1)
#robot = DriveBase(left_motor, right_motor)
# Write your program here.
ev3.speaker.beep()
left_motor.run_time(1000, 5000, wait=False)
right_motor.run_time(1000, 5000,)
ActAngle = gyro.angle()
Desired_angle = ActAngle * -1
servo.run_target(100, then=Stop.HOLD)