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)

First Python Program

PreviousFiddle with RB Command-lineNextKnow Your Libraries

Last updated 6 years ago

Was this helpful?

The ruggedBOARD A5D2x comes with an inbuilt python interpreter, let us see some simple examples of running small python codes on your board. Let's dive in.

There are two ways you can write a python code, 1. Using shell as our python interpreter. 2. Writing code on a text editor (eg: vi, vim, etc..) and using the interpreter to compile it

Using Shell as our interpreter

Step 1: Enter into your board's terminal, type in python3 and hit the <Enter> key

Step 2: Now we are inside an inbuilt python interpreter. Here we can type in some simple python codes and play around for a while. Given below is a screen shot to which you can refer and start off wrinting python codes.

Method 2:

Step 1: Write any python code on a text editor and then save it with a .py extension. You can use the code given below(In our example we save it as add.py)

#Example program in python that adds two numbers.

num1 = 6
num2 = 8
sum = num1 + num2
print("The sum of", num1, "and", num2, "is:", sum)

Step 2: Run the code using python3 add.py

You should be able to see the output as The sum of 6 and 8 is: 14

Example Python codes.
Python using Method2