Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Color data collector for ev3
#!/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