Last active
March 27, 2018 23:59
-
-
Save WestonReed/cfc0f3f6ab62657d680c9b84978bc273 to your computer and use it in GitHub Desktop.
Data Collection Python Script for Raspberry Pi with Sense Hat
This file contains hidden or 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 | |
filename = input('Enter a name for the file: ') | |
filename = filename+".csv" | |
cl = ColorSensor() | |
cl.mode='RGB-RAW' | |
with open(filename, 'w') as logfile: | |
fieldnames = ['red', 'green', 'blue'] | |
logwriter = csv.DictWriter(logfile, fieldnames=fieldnames) | |
logwriter.writeheader() | |
for x in range(0,1500): | |
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