Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """CircuitPython Essentials Analog In example"""
- import time
- import board
- from analogio import AnalogIn
- from digitalio import DigitalInOut, Direction
- led = DigitalInOut(board.LED)
- led.direction = Direction.OUTPUT
- analog_in = AnalogIn(board.A1)
- def get_voltage(pin):
- return (pin.value * 3.3) / 65536
- while True:
- print(get_voltage(analog_in))
- val = get_voltage(analog_in)
- if val >= 1.5: # Greater than 1.5 volts
- led.value = True
- else:
- led.value = False
- time.sleep(1.0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement