Saturday, January 9, 2016

Intel Edison: LED Blinker

Here's a "hello world" test application for Intel® Edison Compute Module. As what the title says, it's just a simple LED blinker task executed by a fast processor.


Below is the tiny module powered by Intel Atom dual-core processor at 500 MHz, with 1 GB DDR3 RAM, 4 GB eMMC Flash, Bluetooth 4.0 and Wi-Fi. It runs Yocto Linux (Linux 3.10.17-poky i686).


Some Intel Edison breakout boards that are shield-like (can be stacked on each other) are also already available on SparkFun. Most useful one is the base block which is used for connecting the Edison module to the host PC via USB. This block has two mini USB ports. The first port is an OTG type and is primarily used for flashing firmware/image of the Edison. The other one is an FTDI-based USB-to-Serial which is used for connecting to a host's serial terminal/console.


Initial configuration requires the Edison module to be connected to a serial terminal, like putty (sample boot log). After configuring the WiFi and the root's password, it is now possible to access the module remotely using ssh connection, just like in the demo video above.

The code below is a simple C++ code for blinking an LED connected at GP14. The code depends on mraa low level library to access the GPIO hardware.
/* intel edison led blink - yus 20150109 */

#include <mraa.hpp>
#include <iostream>

int main()
{
    mraa::Gpio *gpio = new mraa::Gpio( 36 /*=GP14!*/ );
    if (gpio && gpio->dir(mraa::DIR_OUT)==mraa::SUCCESS)
    {
        std::cout<<"Blinking GP14. Press [CTRL+C] to stop...\n";
        while (1) {
            gpio->write(1);
            sleep(1);
            gpio->write(0);
            sleep(1);
        }
    }
    return -1;
}

The provided Yocto Linux installed in the Edison already includes a GNU toolchain (GCC 4.9). So the demo code  can be compiled/build inside the Edison itself.


Alternatively, a BASH script can be also used to do a LED blink task.
#!/bin/bash

# select led pin
pin=14

gpio=/sys/class/gpio/gpio$pin

if [ ! -d "$gpio" ]; then
    echo $pin > /sys/class/gpio/export
fi

echo out > $gpio/direction
echo Blinking GP$pin. Press [CTRL+C] to stop...
while :
do
    echo 1 > $gpio/value
    sleep 1
    echo 0 > $gpio/value
    sleep 1
done

Also, for those who are comfortable developing with Arduino IDE, the Arduino IDE also supports Intel Edison. However, you need to check the correct pin mappings if you're going to use boards other than Arduino's Edison kit or Edison breakout board.



References:
Edison Getting Started
Edison GPIO block
Flashing Firmware
mraa low level library

7 comments:



  1. Your style is unique compared to other people I have read stuff from.Thank you for posting when you have the opportunity, Guess I will just bookmark this page.
    8051 microcontroller training in chandigarh

    ReplyDelete
  2. Useful Information
    one and only affiliate agency in south INDIA, earn money online from affiliate network in india http://publishers.praiseads.com/

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Thanks for sharing the information and keep updating us.This information is really useful to me.
    PHP industrial training in Mohali

    SEO Training Mohali
    Thanks for sharing...!!

    ReplyDelete
  5. Android is a versatile working framework dependent on Linux portion. It enables engineers to compose oversaw code utilizing Java programming dialect. This course is intended for Java software engineers who need to kick begin their professions in portable application advancement. Our Advance Android Programming Course is now Live on Udemy.com and Techgig.com -- Check out at the following Links. http://9itech.com/6-months-training-in-android.php

    ReplyDelete
  6. By choosing PG accommodation in Gurgaon, you do not have to worry about paying separate charges for repair and maintenance of the room in which you are living. Your landlord will provide you neat and clean room. And if there is any repair required, then the landlord will bear the expenses. https://shreedurgapg.com/pg-accommodation-in-gurgaon/

    ReplyDelete