Skip to content

Commit

Permalink
Merge pull request #10 from IDATT1004-Team13-H2025/oving_2
Browse files Browse the repository at this point in the history
Fungerende funksjonalitet
  • Loading branch information
martaron authored Sep 3, 2025
2 parents 8c401b0 + a398e81 commit f0c56b3
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions oving_2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,43 @@

# Write your program here.
ev3.speaker.beep()



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

startBtn = TouchSensor(port=Port.S1)
usSensor = UltrasonicSensor(port=Port.S3)

isPressed = False

next_turn = 0

while True:
if(startBtn.pressed() and isPressed == False):
ev3.speaker.say("Excercise 2")
wait(500)
isPressed = True
next_turn = 1

elif(isPressed == True):
if startBtn.pressed():
isPressed = False
break

elif(usSensor.distance() >= 75):
robotDriveBase.drive(-250, 0)
else:
robotDriveBase.turn(90 * next_turn)
robotDriveBase.straight(-150)
robotDriveBase.turn(90 * next_turn)
next_turn *= -1

robotDriveBase.stop()
ev3.speaker.say("Excercise done")



print("The end..")

0 comments on commit f0c56b3

Please sign in to comment.