forked from BothellRobotics/PythonClass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathev3ColorSensorRead.py
More file actions
32 lines (24 loc) · 801 Bytes
/
ev3ColorSensorRead.py
File metadata and controls
32 lines (24 loc) · 801 Bytes
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
#!/usr/bin/env python3
from ev3dev2.motor import MoveTank, OUTPUT_A, OUTPUT_D
from ev3dev2.button import Button
from ev3dev2.sensor.lego import ColorSensor
from ev3dev2.display import Display
from time import sleep
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s %(levelname)5s: %(message)s')
log = logging.getLogger(__name__)
log.info("Starting Reflected Light Reader program")
btn = Button()
tankMove = MoveTank(OUTPUT_A, OUTPUT_D)
cs = ColorSensor()
d = Display()
try:
while not btn.any():
intensity = cs.reflected_light_intensity
strIntensity = str(intensity)
log.info(strIntensity)
sleep(0.5)
except (GracefulShutdown, Exception) as e:
log.exception(e)
log.info('Exiting Reflected Light Reader Program')