'''
example name：ADC - Voltage measurement
version：v1.0
date：2020.3
Author：01Studio
Forum: forum.01studio.org
'''

#import related modules
from gpiozero import MCP3004
from time import sleep

#initialize MCP3004
adc = MCP3004(channel=0)

while True:
    
    V = adc.value*3.3      #Collection range：0-1; Converted to voltage value: 0-3.3V
    print("%.2f"%V + ' V') #Keep 2 decimal places
    sleep(1)
    