TMC - 8 Digital Tech
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto mode

Starter code

This is a good base to use at the top of each of your projects.

 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
31
32
33
34
35
36
37
38
39
#!/usr/bin/env pybricks-micropython 

from pybricks.hubs import EV3Brick 
from pybricks.ev3devices import Motor 
from pybricks.parameters import Port, Stop
from pybricks.robotics import DriveBase 
from pybricks.tools import wait 
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, InfraredSensor, UltrasonicSensor, GyroSensor) 

# Initialize the EV3 Brick. 
ev3 = EV3Brick() 

""" 
Setting up motors and sensors
------------------

It is vital that you correctly tell the EV3
what sensors it will need and where they are connected.

Any sensors listed below MUST be present on the listed ports.
You can comment out one or more of these lines if you need
to temporarily ignore a sensor.
""" 

# Initialize the motors. 
left_motor = Motor(Port.B) 
right_motor = Motor(Port.C) 

# Initialize the sensors.
touch_sensor = TouchSensor(Port.S1) 
color_sensor = ColorSensor(Port.S3) 
ultrasonic_sensor = UltrasonicSensor(Port.S4) 

# Initialize the drive base. 
robot = DriveBase(left_motor, right_motor, wheel_diameter=55.5, axle_track=104)

# ------------------------
# Write your program here.
# ------------------------