Skip to content
Discussion options

You must be logged in to vote

Hello,

I cleaned up your program.
There were syntax errors, probably because you made the program simpler for us.

First step:

from pybricks.hubs import TechnicHub
from pybricks.pupdevices import Motor, ColorDistanceSensor
from pybricks.parameters import Port, Color

#Initialize hub, motor, and color sensor
hub = TechnicHub()
motor_c = Motor(Port.C)
color_distance_sensor = ColorDistanceSensor(Port.D) # Color sensor on Port D. Don't forget

#Motor settings, don't change
speed = 120
angle_aim = 90 # how far to turn when gray detected

while True:
    color = color_sensor.color() # read color
    if color == Color.GRAY:
        #Aim at the object by rotating motor to target angle
        motor_c

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@sillyguy28093214
Comment options

@sillyguy28093214
Comment options

Comment options

You must be logged in to vote
2 replies
@sillyguy28093214
Comment options

@BertLindeman
Comment options

Answer selected by sillyguy28093214
Comment options

You must be logged in to vote
1 reply
@sillyguy28093214
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants