-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
35 lines (27 loc) · 931 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor, InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port, Stop, Direction, Color, Button
from pybricks.tools import wait, StopWatch, DataLog
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile
ev3 = EV3Brick()
msx = Motor(Port.A)
msd = Motor(Port.D)
radar = InfraredSensor(Port.S4)
robot = DriveBase(msx, msd, 43, 152)
startUpFase = False
runningFase = False
def checkDistanceToWall(InfraredSensor):
distance = InfraredSensor.distance()
if distance == 20 or distance < 20:
return "Distanza <= 20%"
else:
return "Distanza > 20%"
while True:
ev3.wait(100)
ev3.screen.clear()
ev3.scrren.print(checkDistanceToWall(radar))
while startUpFase:
proceed = False
robot.straight(100)