Skip to content

Instantly share code, notes, and snippets.

@thisMagpie
Created February 2, 2016 11:24
Show Gist options
  • Save thisMagpie/234ce988237f317f05b1 to your computer and use it in GitHub Desktop.
Save thisMagpie/234ce988237f317f05b1 to your computer and use it in GitHub Desktop.
from webiopi.devices.analog import MCP3208
import pylab
import numpy as np
from datetime import *
time = datetime.now().microsecond
print(time)
ADC0 = MCP3208(chip = 0)
print("Analog Channel Count {0}").format(ADC0.analogCount())
print("Analog Bit Resolution {0}").format(ADC0.analogResolution())
print("Analog Maximum {0}").format(ADC0.analogMaximum())
print("Analog Reference Voltage {0}").format(ADC0.analogReference())
x = [0.0]*100
y = [0.0]*100
for i in range(len(x)):
y[i] = ADC0.analogRead(3)
x[i] = datetime.now().microsecond
pylab.plot(x, y)
pylab.xlabel('Time ')
pylab.ylabel('Bit Resolution')
pylab.title('Bit Resolution vs Sample No.')
pylab.grid(True)
pylab.savefig("sample_3_4.pdf")
pylab.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment