Update 'Follow_the_line/Programs /Follow_line_color_recognition.py'

This commit is contained in:
Tanja Sukal 2024-09-10 12:33:43 +00:00
parent 2fdc828608
commit 38e98e4dab

View File

@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Version 1.2 from 02/08/23
from time import sleep
import ev3dev2 as ev3
from ev3dev2.motor import Motor, SpeedPercent, OUTPUT_A, OUTPUT_B, OUTPUT_C, OUTPUT_D
@ -27,10 +27,10 @@ speed_percent_both = 30 # speed percentage when both motors rotate (should be le
# while-loop: the robot drives as long as the programm is not stopped
while True:
# if-functions: for different actions when the Colorsensors detect the defined line-color
# if-functions: for different actions when the color sensors detect the defined line-color
# after every function is a sleep set because it is enough to give the motors signals every 100 ms
# when the colorsensors detect black the function: .color is equal to 1 (one)
# when the color sensors detect black the function: .color is equal to 1 (one)
if cs_right.color == line_color and cs_left.color != line_color: #if the right coloursensor detects the defined line-color, the robot drives faster to the right
leds.set_color("LEFT", "GREEN") # the left led lights green
leds.set_color("RIGHT", "AMBER") # the right led (side which detected black) lights amber