[vc_row][vc_column width=”1/1″][vc_tour][vc_tab title=”Hardware list” tab_id=”1389153395-1-91″][vc_column_text]1*pcDuino V1
1*Linear/Slide Potentiometer of Linker Kit for pcDuino/Arduino
Some wires[/vc_column_text][/vc_tab][vc_tab title=”Connection diagram” tab_id=”1389153395-2-55″][vc_column_text]
Potentiometer connects to pcDuino’s A2/GND/5VCC pins
[/vc_column_text][/vc_tab][vc_tab title=”Download Python’s library file” tab_id=”1389153906672-2-10″][vc_column_text]
git clone https://github.com/pcduino/python-pcduino.git
Next we creat a adc_test file under Samples folder, and code is as below:
- import time
- from adc import analog_read
- def delay(ms):
- time.sleep(1.0*ms/1000)
- def setup():
- print “read channel ADC2 value ,the V-REF = 3.3V”
- delay(3000)
- def loop():
- while(1):
- value = analog_read(2)
- voltage = (value * 3.3)/4096
- print (“value = %4d”%value)
- print (“voltage = %4.3f V” %voltage)
- delay(100)
- def main():
- setup()
- loop()
- main()
Save and compile
- python adc_test.py
Display output, adjust the potentiometer, the numerical changes.
[/vc_column_text][/vc_tab][/vc_tour][/vc_column][/vc_row]
Leave a Reply
You must be logged in to post a comment.