The example code for GPIO on mraa usage with C++ can be found from:


Example of using LEDs in Python:

To turn on LED100:

root@intel-corei7-64:~# python
Python 2.7.12 (default, Dec 27 2016, 18:31:23)
[GCC 5.4.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import mraa
>>> led = mraa.Gpio(100)
>>> led.dir(mraa.DIR_OUT)
>>> led.write(1)

To show LEDs rotating, generate file

import mraa
import time
def main():
  # Define the leds from expansion board
  leds = [mraa.Gpio(100), mraa.Gpio(101), mraa.Gpio(102), mraa.Gpio(103)]
  for led in leds:
    led.dir(mraa.DIR_OUT) # set GPIO to be output
    for led in leds:
      led.write(1) # set led on
      print("Led" + str(leds.index(led))+" status: " + str(
      led.write(0) # set led off
      print("Led" + str(leds.index(led))+" status: " + str(

if __name__ == "__main__": main()

Then run from command line:

root@intel-corei7-64:~# python

Press ctrl-c to stop.

For more complete information about compiler optimizations, see our Optimization Notice.