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.

video

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

6 comments:

  1. Nice Blog.
    First Telugu contains telugu political news, latest news in telugu, telugu film news, Tollywood news, ap news, telangana news, movie trailers and movie reviews.

    ReplyDelete
  2. korada provides telugu political news and telugu movie news accurately. You can get genuine telugu political, cinema news current affairs, andhra news, telangana news and all latest news @ korada.com

    ReplyDelete


  3. 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
  4. Nice Post.
    Papajobs provides information about today walkins, it jobs, job notifications

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

    ReplyDelete