summaryrefslogtreecommitdiff
path: root/liboctopus/python/demos/adc.py
blob: 338eea9a1d2566bd8817ab0a2770fecf491af479 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from  octopus import *
import time


op=octopus_context()
octopus_init(op)
octopus_open(op)
octopus_adc_init(op, 33)
octopus_adc_ref(op, 2)


ADC_REV_MV = 5000
while 1:
    value = octopus_adc_get(op, 33)
    value_mv = ((ADC_REV_MV/1024.0) * value) / 4.0
    value_dba = value_mv / 10
    print "value={0}, {1}mV, {2}dbA".format(value, value_mv, value_dba)

    time.sleep(0.4)