2014-05-27 10:43:46 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
# Author: Brendan Le Foll <brendan.le.foll@intel.com>
|
|
|
|
|
# Copyright (c) 2014 Intel Corporation.
|
|
|
|
|
#
|
2019-05-09 09:47:11 -07:00
|
|
|
# SPDX-License-Identifier: MIT
|
2018-01-30 11:32:18 +05:30
|
|
|
#
|
|
|
|
|
# Example Usage: Reads integer and float value from ADC
|
2014-05-27 10:43:46 +01:00
|
|
|
|
2014-06-25 17:49:27 +01:00
|
|
|
import mraa
|
2014-05-27 10:43:46 +01:00
|
|
|
|
2018-01-30 11:32:18 +05:30
|
|
|
print(mraa.getVersion())
|
2014-10-16 14:53:56 +01:00
|
|
|
|
|
|
|
|
try:
|
2018-01-30 11:32:18 +05:30
|
|
|
# initialise AIO
|
2014-10-16 14:53:56 +01:00
|
|
|
x = mraa.Aio(0)
|
2018-01-30 11:32:18 +05:30
|
|
|
|
|
|
|
|
# read integer value
|
|
|
|
|
print(x.read())
|
|
|
|
|
|
|
|
|
|
# read float value
|
|
|
|
|
print("%.5f" % x.readFloat())
|
2014-10-16 14:53:56 +01:00
|
|
|
except:
|
2018-01-30 11:32:18 +05:30
|
|
|
print("Are you sure you have an ADC?")
|