# Python Programming using MRAA (gpio\_blink)

Python Programming using MRAA (gpio\_blink)

1. Targeted Hardware   &#x20;

SOM Version: PICM-001-A1

CB : RuggedBoard-A5D2X

CB Version : RB-A5D2X-V1.1

1. Targeted Software   &#x20;

BSP-Yocto-A5D2X 2019-03-13

* AT91Bootstrap-3.8.12
* Linux Kernel v4.9.151
* uboot-2018-07
* Yocto 2.5.2 (sumo HEAD commit 623b77885051)

Description

* Here is the simplest OnBoard-Gpio's program in mraa,to toggle three GPIO pins – 61,62,63

Required Hardware

* a5d2x-rugged board
* USB cable

Step-by-step guide

* Connect the Rugged board to your system
* Boot the board with SD card/NOR.
* Copy the below python file to data directory of rugged board through tftp protocol.

Test On-board LEDs – gpio\_blink.py

* Open gpio\_blinky.py program given below in your board terminal.
* Open the gpio\_blinky.py program in /data directory.

PROGRAM: gpio\_blinky.py

`import mraa import time`\
`gpio_1 = mraa.Gpio(61)     # set gpio 61 to output                                                                                                                                  gpio_2 = mraa.Gpio(62)           # initialise gpio 62 (D4 – Ref: Schematic)`\
`gpio_3 = mraa.Gpio(63)        # initialise gpio 63 (D17)`\
`gpio_1.dir(mraa.DIR_OUT)                                                                                                                               gpio_2.dir(mraa.DIR_OUT)` \
`gpio_3.dir(mraa.DIR_OUT)                                                                                                                                             while True:`\
`gpio_1.write(1)`\
`gpio_2.write(0)                                                                                                                                              gpio_3.write(1)`\
`time.sleep(1)`\
`gpio_1.write(0)`\
`gpio_2.write(1)                                                                                                                                                   gpio_3.write(0)`\
`time.sleep(1)`\
`gpio_1.write(0)`\
`gpio_2.write(0)`\
`gpio_3.write(1)`\
`time.sleep(1)`

Execution :

* Run the above code with below command in rugged board.

root\@ruggedboard-a5d2x:/data# python3 gpio\_blinky.py

Expected Output:

root\@ruggedboard:/data# python3 gpio\_blink.py                                                                                            libmraa\[145]: libmraa version v2.0.0 initialised by user 'root' with EUID 0                                                libmraa\[145]: gpio: platform doesn't support chardev, falling back to sysfs                                             libmraa\[145]: libmraa initialised for platform 'Atmel SAMA5' of type 20                                                                  gpio 77                                                                                                                                                                         gpio pin 77                                                                                                                                                                     gpio 81                                                                                                                                                                            gpio pin 81                                                                                                                                                                                    gpio 83                                                                                                                                                                                           gpio pin 83          ( NOTE:  Toogling of LED's can be seen on the ruggedboard a5d2x).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ruggedboard.gitbook.io/ruggedboard/lib-mraa-and-upm-sensor-libraries/know-your-libraries/libmraa/python-programming-using-mraa-gpio_blink.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
