detection done at runtime you can create portable code that will work across the supported
platforms. UPM is a high level repository for sensors that use MRAA. Each sensor links to
MRAA and are not meant to be interlinked although some groups of sensors may be. Each
sensor contains a header which allows to interface with it. Typically a sensor is represented as a
class and instantiated.The constructor is expected to initialise the sensor and parameters may be
used to provide identification/pin location on the board.
Install and update
Mraa and UPM are already installed in the system image of BBGW, so
you don’t need to install
it.
However if you want to update the library, or want to upgrade the library, use
apt
‐
get
update
and
apt
‐
get
upgrade
please. Refer to
https://github.com/intel-iot-devkit/mraa
and
https://github.com/intel-iot-devkit/upm
for more information.
Mraa Example
light a led
import
mraa
import
time
#mraa
.gpio60
=
P9_14
=
GPIO_50
led
=
mraa.
Gpio
(60)
led.
dir
(mraa.DIR_OUT)
while
True:
led.
write
(1)
time
.
sleep
(1)
led.
write
(0)
time
.
sleep
(1)
Grove - PIR Sensor
import
mraa
import
time
#mraa
.gpio73
=
P9_27
=
GPIO_115
pir
=
mraa.
Gpio
(73)
pir.
dir
(mraa.DIR_IN)
while
True:
(pir.
read
()
)
time
.
sleep
(1)
Grove - Rotary Angle Sensor
import
mraa
import
time
#mraa
.aio1
=
AIN0
rotary
=
mraa.
Aio
(1)
Summary of Contents for BBGW
Page 22: ......