Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Odin Grav committed Sep 17, 2025
1 parent bb5f06f commit 8899850
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions oving_3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from rtttl_player import RTTTLPlayer
from random import randint
import time



Expand Down Expand Up @@ -38,7 +39,7 @@
#player.play()

leftMotor = Motor(port=Port.A)
rightMotor = Motor(port=Port.B)
rightMotor = Motor(port=Port.C)
robotDriveBase = DriveBase(leftMotor, rightMotor, wheel_diameter=56, axle_track=110)

startBtn = TouchSensor(port=Port.S1)
Expand All @@ -47,11 +48,28 @@
leftColorSensor = ColorSensor(port=Port.S2)
rightColorSensor = ColorSensor(port=Port.S4)

BLACK = 9
WHITE = 85
threshold = (BLACK + WHITE) / 2

lastCorrectino = time.time()
lastDirection = 1

while True:
if leftColorSensor.color() == Color.BLACK:
robotDriveBase.turn(5)
if time.time() - lastCorrectino > 1:
while leftColorSensor.reflection() > 10 or rightColorSensor.reflection() < 10:
robotDriveBase.drive(-100, 50 * lastDirection)

elif rightColorSensor.color() == Color.BLACK:
robotDriveBase.turn(-5)
if leftColorSensor.reflection() < 10:
robotDriveBase.drive(-100, 50)
lastCorrectino == time.time()
lastDirection = 1
continue

DriveBase.run(100)
elif rightColorSensor.reflection() < 10:
robotDriveBase.drive(-100, -50)
lastCorrectino = time.time()
lastDirection = -1
continue

robotDriveBase.drive(-100, 50)

0 comments on commit 8899850

Please sign in to comment.