XOR Simulation using Arduino

In this post, an experiment with Arduino to create a setup which simulates the XOR truth tables using two tactile buttons and an LED is explained.  The circuit setup is as below. The diagram is created using Fritzing – An EDA tool (Check it out!)


Setting up the Arduino IDE in GNU/Linux :

Dowload the latest version of the Arduino IDE.

After downloading, extract the archive and the execute the arduino script to open the IDE.

After opening the IDE, set the board and port used in the Tools menu. Goto Tools-> Board -> Arduino UNO (or any board which you use). Then again goto Tools -> Serial Port -> /dev/ttyACM0 (or any other port to which the arduino is connected.) To check which port the arduino is using, you can disconnect and reconnect the Arduino USB and check kernel logs using ‘dmesg’ command. For Arduino UNO (which is an ACM device) you will mostly see the following line in dmesg :

[ 1956.390390] cdc_acm 2-1.6:1.0: ttyACM0: USB ACM device (The port is mentioned in the dmesg line)

If you get such a line the port is, as mentioned above, /dev/ttyACM0.

After setting the IDE, you can start a new Sketch and use the below code to setup the Arduino.

 Xor Buttons

 Turns on and off a light emitting diode(LED) connected to digital
 pin 13, when pressing a pushbuttons attached to pin 2 and pin 4 based
 on the XOR truth table

 The circuit:
 * LED attached from pin 13 to ground
 * pushbutton attached to pin 2 from +5V
 * pushbutton attached to pin 4 from +5V
 * 10K resistor attached to pin 2 from ground
 * 10K resistor attached to pin 4 from ground

 * Note: on most Arduinos there is already an LED on the board
 attached to pin 13.

 created 2005
 by DojoDave
 modified 30 Aug 2011
 by Tom Igoe
 modified from original "Button" code on 30 Mar 2013
 By Rajgopal

 The original Button code is an example code is in the public domain.


// constants won't change. They're used here to
// set pin numbers:
const int buttonPin1 = 2;     // the number of the pushbutton1 pin
const int buttonPin2 = 4;    // the number of the pushbutton2 pin
const int ledPin =  13;      // the number of the LED pin

// variables will change:
int buttonState1 = 0;         // variables for reading the pushbutton status
int buttonState2 = 0;

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbuttons pin as an inputs:
  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);

void loop(){
  // read the state of the pushbuttons value:
  buttonState1 = digitalRead(buttonPin1);
  buttonState2 = digitalRead(buttonPin2);
  // check if the pushbuttons is pressed.
  // Based on the pushbutton status and truth table of XOR, turn on or off the LED at Pin 13
  if ((buttonState1 == HIGH && buttonState2 == LOW) || (buttonState1 == LOW && buttonState2 == HIGH)) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW);

First you should “Verify and Compile” the code. Goto Sketch->Verify/Compile. If the compilation and verification is successful, then you can go ahead and upload your sketch’s binary to the Arduino micro-controller. Goto File -> Upload. If the upload is successful, then you can test the setup. Press either one of the tactile button and the LED should glow. If both tactile buttons are pressed together or if both are released together, then the LED shouldn’t glow, thus perfectly simulating XOR gate.

My Arduino UNO R3

Finally! The days of Arduino Hacking is here. I bought my own Arduino UNO from Simplelabs along with the Quick Start kit – the main attraction of which was the solder-less breadboard, the wire-stripper and the screwdriver.. (yeah..like I needed those desperately!).

My Ardiuno UNO

My Arduino UNO R3

Now that I got the Arduino, I wasted no time in pleasing the embedded gods by uploading the classical “hello world” program of the bit world..lovingly called the “Blink”.

The “Blink” is one of the pre-defined example in the Arduino IDE and you just have to verify and compile it and then connect your Arduino board and upload the compiled program image onto the microcontroller. (Yes. there are some pre-requisites before for setting up the IDE and its pretty straightforward. I will write about this setup in the next post.) On successful upload you can usually see the on-board LED named ‘L’ starting to blink. If you are still not convinced with the on-board LED,  you can check the same output by connecting an actual LED between the Port 13 and GND (with Anode[+], which is the longer leg of LED, connected to I/O port 13 and cathode connected to the GND port).

And it shall blink!

The LED in OFF State

LED Turned OFF – Arduino Blink Working

LED turned on

LED Turned ON – Arduino Blink Working

Presenting Non-linear presentations

A presentation aids a public speaker, a professional as well as an academician whenever they step into the limelight to project their idea or achievement to a larger audience. Now, this powerful tool can be made even more impressive by (carefully) adding some non-linearity to the presentation style.

Most of the presentation that we create today is a linear presentation, with a particular order. And although that is a great way of presenting things, sometimes they dull out and sometimes the audience is not immersed enough to understand the completeness of your idea.

If you face such challenges, where you need to get your audience involved in your talk, its a great idea to use a non-linear presentation.

Non-linear presentations are those presentations which uses a series of rotations, translations and zooming levels to emphasize and present the content. Few might consider that calling such type of presentations a Non-linear presentation is a misnomer. Rather it should be called a free canvas mode of presentation where there is a blank canvas where you can put in your entire idea and then emphasize areas where you need the audience attention in order to deliver the idea to them. I agree to that notion but don’t find any fault in calling it non-linear as well, cause it definitely uses rotations!

Now,enough theory..let’s make some presentations. There are many proprietary methods to create a non-linear presentation. Prezi is one among them and like they say.. “When you are creative.. Your ideas matter!”

Now we all can’t afford proprietary software and that is where Open Source steps in to save us. Welcome Sozi. Sozi is an extension of vector graphics tool called Inkscape and using Sozi extensions, you can create SVG files which can be played on most of the modern web browser (like Firefox and Chrome) as a presentation. And since its not flash dependent, iOS devices also shall support it.

So what are we waiting for..let’s jump in and make some non-linear presentations.

The instructions for installing Sozi is present in its website (link given above).

A quick tutorial to get you started is right here.

Enjoy the non-linear presentations! A simple creation from my end is downloadable here. Open it up in a browser!


We all wait for the tides of life to turn in our favor.. For prayers to be heard.. For dreams to be fulfilled…

We all wait for the waiting to end…

Here’s John Burroughs ode to Waiting :

Serene, I fold my hands and wait,

Nor care for wind, nor tide, nor sea;

I rave no more ‘gainst time or fate,

For, lo! my own shall come to me.


I stay my haste, I make delays,

For what avails this eager pace?

I stand amid the eternal ways,

And what is mine shall know my face.


Asleep, awake, by night or day,

The friends I seek are seeking me;

No wind can drive my bark astray,

Nor change the tide of destiny.


What matter if I stand alone?

I wait with joy the coming years;

My heart shall reap where it hath sown,

And garner up its fruit of tears.


The waters know their own and draw

The brook that springs in yonder height;

So flows the good with equal law

Unto the soul of pure delight.


The stars come nightly to the sky;

The tidal wave unto the sea;

Nor time, nor space, nor deep, nor high,

Can keep my own away from me.



by: John Burroughs (1837-1921)



IBM’s First

IBM, as announced, is changing its CEO w.e.f Jan 1,2012. Virginia “Ginni” M. Rometty, is going to be the new CEO.

A few weeks ago when HP, another tech behemoth, gave its reins to Meg Whitman there was a huge speculation of HP trying to follow suit of IBM by bringing in an outsider to lead them out of the messy situation. IBM did that in early 90’s by bringing in Lou Gerstner Jr., the only non-IBMer, who was directly made the CEO. Now there is speculation if IBM is trying to follow suit of HP by appointing a female leader. But these speculation really don’t matter, for both companies are bellwether’s in technology and both leaders able and experienced. And again, HP is not following IBM’s history..there won’t be any spin off’s of the PC business from HP’s side although it was decided so by their earlier leadership.

What’s interesting about Virginia Rometty’s appointment is the fact that she is not only the first women to be at the helm of IBM, but she is also the first Engineer to reach the helm. All other CEO’s at IBM as accounted by this site was from the sales and marketing side.

Here’s wishing Ginni, IBM’s first woman engineer CEO the best!

The Sam Roweis Quote

I have been mentored by many good people in my life and that’s one of the greatest blessing ever. One of my mentors, Sumod, oft quotes Sam Roweis.

The quote is :

“I say never let go, never rest, never stop, never give in, never show fear, never tire. Cleaner, faster, better than everybody else, more practice, later nights, earlier mornings. Only the mediocre are always at their best. Push yourself. Keep fire in your eyes and fire in your heart and always do what you think is the right thing.”

This quote somehow gives me small shudders as sudden sadness hits me…and then all of a sudden there is a warm feeling to live through every new circumstances life throws at you. To dare and live above average! To resist mediocrity!

The sadness in hearing that quote is related to Sam’s demise and his memorial blog. I don’t know Sam personally or professionally, but the memorial blog for the brilliant soul many knew often brings tears to my eyes..

I feel helpless, as helpless and sad as his colleagues friends and family. All I can do is pray for all the people who are affected.

Sam shall continue to be an inspiration for me and for many others.