Arduino Hacks

Arduino is an open-source hardware platform based on a simple controller board and a development environment that implements the Processing/Wiring language. Arduino can be used to develop various interactive objects or can be connected to software on your computer. More information and software can be found at We will be using a Arduino clone, aptly named as Freeduino for our work.


Displaying the visitors on your WordPress blog

In this hack we will see how to display the total numbers of visitors online on a LCD display using the Arduino. Before we start playing with the hardware part, we need to somehow get the visitor count from the blog. The first thing we need to do is define a proxy that will return the results from our WordPress site. For this we will use the code developed in one of my previous posts.

Arduino prototype shield

Breadboards are wonderful for testing new circuit ideas, but once a design is done it is better to create a permanent circuit on a PCB.

The Protoshield is a Arduino compatible board that connects with the Arduino USB board and gives the user a small soldering area on which one can design new curcuits, two general LEDs and a single tact switch which works as a Arduino reset button. A blank shield is shown below.

arduino prototype shield

The above shield after the LCD module has been soldered on.
arduino prototype lcd module

The prototype shield backside. The tangle of wires could have been soldered beneath the LCD, thus hiding them, but it would make it difficult to change the wiring if the need arises.

arduino prototype board backside

LCD pin connections

The following table shows the pin details of the LCD.

LCD Pin Number Symbol Function
1 Vss Display power ground
2 Vdd Display power +5V
3 Vo Contrast Adjust. Altered by adjusting the voltage to this pin, grounding it sets it to maximum contrast.
4 RS Register select
5 R/W
6 E Enable strobe
7 DB0 Data Bus 0
8 DB1 Data Bus 1
9 DB2 Data Bus 2
10 DB3 Data Bus 3
11 DB4 Data Bus 4
12 DB5 Data Bus 5
13 DB6 Data Bus 6
14 DB7 Data Bus 7
15 A

LED backlight power +5V
16 K LED backlight power ground

Connecting the LCD to the Arduino

You need to connect the correct data pins of the LCD to the Arduino. The pin details are given below.

Arduino Pin LCD Pin LCD Pin Name
2 4 RS
3 5 RW
4 6 Enable
5 3 Contrast (grounded with a variable resistor)
9 11 Data 4
10 12 Data 5
11 13 Data 6
12 14 Data 7

Arduino code

The following is the Arduino code to monitor the serial port and print the message passed by the Processing applet.

/* Arduino code */

/* include the LCD library code */

char buffer[100];

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2, 3, 4, 9, 10, 11, 12);

void setup()
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // initialize the serial communications:

void loop()
  int count = 0;
  // when characters arrive over the serial port...
  if (Serial.available()) 
    // wait a bit for the entire message to arrive
    // clear the screen
    lcd.setCursor(0, 1);
    // read all the available characters
    while (Serial.available() > 0) 
      // display each character to the LCD
      lcd.print(, BYTE);

Processing code

Below is the Processing code that accesses my blog and gets the total users online as a JSON response.

/* Processing code */

import org.json.*;
import processing.serial.*;

int       result;
boolean   error = false;
String    total;

Serial    myPort;
String baseURL = "";

void setup() 
  size(4, 4);
  myPort = new Serial(this, Serial.list()[1], 9600);

void draw() 
  /* Get the total users by connecting to the site */
  if(error == false)
    myPort.write("Total Users : " + total);
    myPort.write("Error connecting...");
    error = false;
  /* Wait for 5 seconds before re-checking */

void getSiteData() 
    JSONObject siteData = new JSONObject(join(loadStrings(baseURL), ""));
    total = str(siteData.getInt("total"));
  catch (JSONException e) 
    error = true;
    println ("There was an error parsing the JSONObject.");

The final result

The following image shows how the final result looks like after connecting everything. The display now shows the total visitors currently online on my blog. Casual users will balk with the idea of going all this way to just display a user count on a LCD. But the essential element lies not with the end result but with the spirit of tinkering and experimentation; connecting things up and seeing it work.

arduino final

The next step

A much better way to connect to a website will be to use the Arduino Ethernet shield. This will allow me bypass the PC completely and will directly connect the Arduino to the Internet.

Arduino Ethernet Shield

2 thoughts to “Arduino Hacks”

Leave a Reply

Your email address will not be published.