Created
March 27, 2018 23:54
-
-
Save WestonReed/1e490b663b3112400c38fc4213b68088 to your computer and use it in GitHub Desktop.
Color data collector for ev3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from ev3dev.ev3 import * | |
import csv | |
import time | |
cl = ColorSensor() | |
cl.mode='RGB-RAW' | |
with open(filename, 'w') as logfile: | |
fieldnames = ['red', 'green', 'blue'] | |
logwriter = csv.DictWriter(logfile, fieldnames=fieldnames) | |
logwriter.writeheader() | |
while True: | |
red = cl.value(0) | |
green = cl.value(1) | |
blue = cl.value(2) | |
logwriter.writerow({ | |
'red' : red, | |
'green' : green, | |
'blue' : blue | |
}) | |
time.sleep(.1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment