Skip to content

Instantly share code, notes, and snippets.

@WestonReed
Created March 27, 2018 23:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WestonReed/1e490b663b3112400c38fc4213b68088 to your computer and use it in GitHub Desktop.
Save WestonReed/1e490b663b3112400c38fc4213b68088 to your computer and use it in GitHub Desktop.
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