Skip to content

Commit bf30d30

Browse files
committed
remove pwm, and add ADC
remove pwm, and add ADC
1 parent 5de3937 commit bf30d30

3 files changed

Lines changed: 39 additions & 26 deletions

File tree

‎Samples/adc_test/adc/__init__.py‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env python
2+
3+
_PIN_FD_PATH = '/proc/adc%s'
4+
5+
6+
def analog_read(channel):
7+
"""Return the integer value of an adc pin.
8+
9+
adc0 and adc1 have 6 bit resolution.
10+
adc2 through adc5 have 12 bit resolution.
11+
12+
"""
13+
14+
15+
with open(_PIN_FD_PATH % channel, 'r') as f:
16+
return int(f.read(32).split(':')[1].strip())

‎Samples/adc_test/adc_test.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import time
2+
from adc import analog_read
3+
4+
def delay(ms):
5+
time.sleep(1.0*ms/1000)
6+
7+
def setup():
8+
print "read channel ADC2 value ,the V-REF = 3.3V"
9+
delay(3000)
10+
11+
def loop():
12+
while(1):
13+
value = analog_read(2)
14+
voltage = (value * 3.3)/4096
15+
print ("value = %4d"%value)
16+
print ("voltage = %4.3f V" %voltage)
17+
delay(100)
18+
19+
def main():
20+
setup()
21+
loop()
22+
23+
main()

‎pcduino/pwm.py‎

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)