Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from LDRone import MCP3008
- import time
- adc = MCP3008(bus=0, device=0, vref=3.3)
- while True:
- voltage = adc.read(channel=0) # across resistor
- current = voltage * 10000 # through resistor and LDR
- resistance = (adc.vref - voltage) / current # of LDR
- print("voltage: \t", voltage)
- print("current: \t", current)
- print("resistance: \t", resistance)
- time.sleep(4)
- #except:
- print("MCP3008 and LDRs!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement