Scripting for Fun and Passion

Category Archives: Uncategorized

Intel Galileo Gen 2 Board for interfacing internet of things: Controlling LED Via Web

If you are following this blog series, I hope you are comfortable with running a big Linux image on your Galileo as explained in my previous post.

In this post we will be using the Intel Galileo board to run a web server which will serve a page for controlling an LED connected to a board. This means that if your board is on a network any user can access the page served by the board and switch the LED on or off. The implications and extensions of this example app can be for controlling any device connected to the board via the web.

In this post we will work using a different linux image called the Internet of Things version. This image comes with many plugins for interfacing the with the GPIO pins and running web servers. You can download this new image from the Intel IoT downloads page. More details on  this image and its usage can be found at the intel pages. Also, I would like to point out that the steps for installing this image on the SD card are quite straightforward but also different from installing the default image I mentioned in my older article and require downloading of additional software. You can find detailed instructions for installing this image for windows platform on the intel page.

Once the image is installed you can connect your device to your router and have it available on your network. Now you can run a web server directly on the image using python or the LightHTTP package which comes with it. However, the Inter IoT community has released an XDK which I will be using in this post to configure the web server and send signals to my GPIO pins to switch the LED on/off. The XDK is for running Node.js code on the board and comes with sample code for interfacing with the pins.

The XDK will detect the board if it is present on the network and will deploy the code. It has easy options for starting the deployed app and stopping it all without physically connecting to the Galileo. The editing experience on it is a bit clunky but it serves the purpose of file deployment. I edited my main code in another editor and used the XDK only for deployment.

I used the IoT local temperature example as a template and modified its code to configure the Node.js server and the board interaction.

The app requires 3 important components and all the code is available at:

  1. LED circuit connected to Galileo
  2. Web page with On/Off switch served by the Galileo
  3. Sending the input from web page to the pins.

The final product looks like the following images (click image for more pics):

LED circuit with Intel Galileo

LED circuit with Intel Galileo


In my web app I have used the plugin for sending and receiving the signals asynchronously. The main component of the code for interfacing with the GPIO pins is the one using mraa plugin.

var mraa = require('mraa'); //require mraa
console.log('MRAA Version: ' + mraa.getVersion()); //write the mraa version to the Intel XDK console
var myOnboardLed = new mraa.Gpio(13); //LED hooked up to digital pin 13 (or built in pin on Galileo Gen1 & Gen2)
myOnboardLed.dir(mraa.DIR_OUT); //set the gpio direction to output
var ledState = false; //Boolean to hold the state of Led

After initializing the pins we just need to use the following piece of code to switch the LED on/off.

myOnboardLed.write(1); //Send High leading to LED ON
myOnboardLed.write(0); //Send Low leading to LED OFF
LED On Off Web Interface

LED On Off Web Interface

Overall this was a major step for me in understanding the concept of internet of things and getting my first internet of thing (simple LED) to be controlled over the internet at the flick of a button.

2014 in review

The stats helper monkeys prepared a 2014 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 39,000 times in 2014. If it were a concert at Sydney Opera House, it would take about 14 sold-out performances for that many people to see it.

Click here to see the complete report.

Sosan Sontag – On Love

Sosan Sontag - On Love

Nothing is mysterious, no human relation. Except love.

Programming fundamentals not to forget

A Programmer's KISS

A Programmer’s KISS

Read it in the comments section of this post:

What would be the fundamentals that a good programmer might forget?

KISS. RTFM. PEBKAC. DRY. If it ain’t broken, don’t fix it. Cheap, fast, accurate; pick two. If your program is idiot-proof, they’ll find a better idiot. Any piece of software reflects the organizational structure that produced it.

The details of the acronyms used are as follows:

  1. KISS – Keep ISimple and Stupid
  2. RTFM – Read The F***ing Manual
  3. PEBKAC – Problem Exists Between Keyboard And Chair
  4. DRY – Don’t Repeat Yourself

If you are more interested in Programming Acronyms you can read this detailed link:

If you know any other interesting Programming Acronyms do post them in the comments section. I will add the best ones to the this post as update.

First victory in GO

I have recently watched a History channel Documentary on the book the ART OF WAR by Tan Zu. Tan Zu is said to be the greatest strategist of all time and he was famous for devicing ways to win wars against larger adversary armies through the minimal usage of resources.

This post is not about the art of war but something which guided Tan Zu in making those decisive strategies. The game is called GO and is and can be considered like chess in a manner that it pits 2 sides with black and white peices respectively, against each other. The concept of GO is however, pretty different than chess. In chess, the strategy is to take on your opponent head on and kill as many peices as possible, eventually killing the King. However, in GO the idea is to capture as much territory without killing many peices.

My played my first few games of GO online and lost in first few moves. The game rules are very few and simple but that is what makes the game so fast and tough. You have the freedom to use tactics of deception and diversion. The strategy is to get as much of the opposition army to be eclosed by as few peices of yours. The game shows wonderful examples of building small but powerfully connected army. Also the fact which makes it exciting is that you can divert your opponent by passing your chances or placing peices at non contnous places.

Overall playing the game is a good thinking exercise. Below is the winning board configuration of my first win against the AI on the android app.


First win at GO

You can also try the game at these places:

Online – Go online
Android – Go Free: Google Play
Board Game –

%d bloggers like this: