Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Vicente Castellano Gómez
/
robotAmbientales
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c251fee7
authored
Apr 22, 2024
by
Vicente Castellano Gómez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Prueba de siguelinea verde
parent
916c040a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
0 deletions
main.py
main.py
View file @
c251fee7
...
...
@@ -33,3 +33,22 @@ def giro(grados):
if
(
ajuste
<
0
):
robot
.
turn
(
-
1
)
def
sigue_linea_verde
():
# Valores medios para los colores
green_threshold
=
(
70
+
100
)
/
2
# Valor medio para el color verde claro
blue_threshold
=
(
0
+
20
)
/
2
# Valor medio para el color azul oscuro
while
True
:
reflection
=
colorSensor
.
reflection
()
if
reflection
>
green_threshold
:
# Si está sobre la línea verde
desviacion
=
reflection
-
green_threshold
turn
=
1.2
*
desviacion
# Correccion hacia la
elif
reflection
<
blue_threshold
:
# Si está sobre la línea azul
desviacion
=
blue_threshold
-
reflection
turn
=
-
1.2
*
desviacion
# Corrección hacia la izquierda
else
:
# Si está entre la línea verde y la azul
turn
=
0
# Avanzar recto
robot
.
drive
(
100
,
turn
)
wait
(
10
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment