ruggedBOARD
Tutorial Using Python
Tutorial Using Python
  • Overview
  • Quick Start with RB
    • Pre-Requisite
      • Required Hardware and Software Components
      • Host Setup
      • Linux Commands
    • Power Up your RB
    • Fiddle with RB Command-line
  • Lib-Mraa & UPM Sensor Libraries (Python)
    • First Python Program
    • Know Your Libraries
      • LibMRAA
        • Python Programming using MRAA (SPI)
        • Python Programming using MRAA (PWM)
        • Python Programming using MRAA (gpio_blink)
        • Python Programming using MRAA (Aio)
      • LibUPM
    • Example Programs for Sensors
      • Procedure to interface phyNODE with RB
      • Accelerometer
      • Temperature Sensor
      • Pressure Sensor
      • Humidity Sensor
      • Magnetometer
      • PIR Sensor
      • Ultrasonic Sensor
      • Gas Sensor (MQ5)
    • mikroBUS UPM Sensor
    • Example programs for Communication Protocols
      • GPIO
      • I2C
      • UART
  • Hello World in C language
    • Setting up Environment
    • Transferring Files from Host to Board
    • Write your first C program
  • IoT Implementation
    • What is IoT?
    • IoT Protocols
    • MQTT Setup
  • Peripherals Functionality Testing using C Language
    • Interfaces
      • GPIO(General purpose Input/Output):
      • UART(Universal Asynchronous Receiver-Transmitter)
      • RS232
      • RS485
      • CAN
      • MikroBUS
      • mPCIe
  • Advance RB
    • Preparing SD card in case of OS failure
Powered by GitBook
On this page

Was this helpful?

  1. Lib-Mraa & UPM Sensor Libraries (Python)
  2. Know Your Libraries
  3. LibMRAA

Python Programming using MRAA (gpio_blink)

Python Programming using MRAA (gpio_blink)

  1. Targeted Hardware

SOM Version: PICM-001-A1

CB : RuggedBoard-A5D2X

CB Version : RB-A5D2X-V1.1

  1. Targeted Software

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).

PreviousPython Programming using MRAA (PWM)NextPython Programming using MRAA (Aio)

Last updated 4 years ago

Was this helpful?