-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlturn.py
30 lines (21 loc) · 799 Bytes
/
lturn.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
#!/usr/bin/env python3
# This program was written for the L turn quick challenge at the start.
# It turns left ALWAYS when black color is not under the color sensor
from ev3dev2.motor import LargeMotor, OUTPUT_A, OUTPUT_B, OUTPUT_C, MoveTank
from ev3dev2.sensor import INPUT_1, INPUT_2, INPUT_3, INPUT_4
from ev3dev2.sensor.lego import ColorSensor
from ev3dev2.button import Button
from ev3dev2.sound import Sound
from time import sleep
button = Button()
colorS = ColorSensor(INPUT_4)
sound = Sound()
tank_pair = MoveTank(OUTPUT_B, OUTPUT_C)
tank_pair.off()
sound.beep()
while True:
intensity = colorS.reflected_light_intensity
if (intensity < 50):
tank_pair.on(-50, -50) # vasemman ja oikean nopeudet
else:
tank_pair.on(-50, 50) # vasemman ja oikean nopeudet