Skip to content

Instantly share code, notes, and snippets.

@thisMagpie
Created November 20, 2015 16:38
Show Gist options
  • Save thisMagpie/b62413a4c22e14a54894 to your computer and use it in GitHub Desktop.
Save thisMagpie/b62413a4c22e14a54894 to your computer and use it in GitHub Desktop.
import webiopi
from webiopi.devices.analog import MCP3208, MCP4922
ADC0 = MCP3208(chip = 0)
DAC1 = MCP4922(chip = 1)
print("Number of DAC1 Outputs: {0} ").format(DAC1.analogCount())
vout = 1.0
vref = DAC1.analogReference()
print "vref {0} {1}".format(vref, ADC0.analogReference())
while (vout < vref):
print "\nSetting output to {0}V on channel 0 of DAC1".format(vout)
for i in range(DAC1.analogCount()):
DAC1.analogWriteVolt(i, vout) # set volatage of output channel VoutA to vout
webiopi.sleep(2.0)
print("DAC1 output voltage of channel {0} {1}").format(i, DAC1.analogReadVolt(i))
print("ADC0 input voltage of channel {0} {1}").format(i, ADC0.analogReadVolt(i))
print " "
vout += 0.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment