Author Archives: Shantanu Sharma

Part II: All Pin Interrupt method for RC in Arduino

I hope you are already aware of the basics of the RC communication and Hardware connection with the Arduino. If you are not, then just have a quick look at the previous blog in the series… 🙂

After looking into the problems of the polling method, The second method to interface the RC is Interrupt method. Well, as you know there are only two external hardware interrupts available in Arduino boards like Uno, Dueminalove etc.. (Ofcourse, Due is an exception 😛 ). For further clarification on this topic, click for Interrupts. I am taking Arduino Uno as a typical example here.

For interfacing all the six channels of RC you need 4 more interrupts. What can we do. Obviously we have to go for the software interrupts.

Here comes the PinChangeInterrupt for the rescue…

What are Pin Change interrupts? The ATmega processor has two different kinds of interrupts: “external”, and “pin change”. There are only two external hardware interrupt pins, INT0 and INT1, and they are mapped to Arduino pins 2 and 3. These interrupts can be set to trigger on RISING or FALLING signal edges, or on low level. Being hardware interrupts, they are very fast.

On the other hand the pin change interrupts can be enabled on any or all of the Arduino’s signal pins (Uno/Duemilanove/Nano). They are triggered equally on RISING or FALLING signal edges, so it is up to the interrupt code to set the proper pins to receive interrupts, to determine what happened (which pin? …did the signal rise, or fall?), and to handle it properly. Furthermore, the pin change interrupts are grouped into 3 “port”s on the MCU, so there are only 3 interrupt vectors (subroutines) for the entire body of 20 pins. This makes the job of resolving the action on a single interrupt even more complicated. The interrupt routine should be fast, but more the complication, lesser is the speed. The PinChangeInt library is designed to handle the Arduino’s pin change interrupts as quickly and reasonably as possible.

Well, how can you use it?? This is just a little finger’s work (literally :P)

1. Download the library from this link.

2. Extract the zip to the Arduino library folder on your computer.

3. Include the header file in the sketchbook.

4. Use it as normal interrupt function.

I used pinchangeint-v1.72, which contained 3 folders: PcChangeInt, cppfix,MemoryFree.

The skeleton sketchbook works like this after the inclusion of PcIntChange library.

PcIntChange Demonstration

Now the RC interfacing part…

We need to define the pinchange Interrupt for all the 6 pins to which channels are attached.

This is the code to get the value of the 1 channel to help you understand the code flow.. Read the rest of this entry

Working with RC and Arduino: Part 1

The HK-T6A V2 is a classic 6-channel RC Transmitter, best option for starters.


The 4 channels are used for flying while rest 2 can be used for landing purposes. It is programmable as well. For that purpose one need to have the programming cable. It requires 12 V as the optimum voltage supply level. However, the status of LED shows the voltage level.


Red : Voltage < 9.1 V

Orange :  9.4 V < Voltage < 10.1 V

Green : 10.4 < Voltage < 12

I used 12 V adapter with 1 A current rating.

Its range is upto 1 km for LOS, which is quite sufficient. Another big point is its cheap receivers, which comes for 9 $ only.

That is enough for the blah blah.. 😛

Getting To The Interfacing Part: Read the rest of this entry

GUI: Plug n Play Duino

The main idea behind the “Plug n Play Duino” model was the ease of implementation of algorithms of line following, edge avoiding and all such sort of works… or “To make it a toy”(in english :P)

As Saurabh gave a detailed list of features of this board here,…a-new-approach/

We built a GUI for this board, which makes it a child play, when it comes to line following.


Line Followe GUI
Line Followe GUI

Well As you can see, the GUI allows you to : Read the rest of this entry

Rotary Encoder

Wheel mounts for rotary encoder

Basically, Rotary Encoder converts the angular motion of wheel or shaft intoanalog or digital codes, and by codes we can count the number of rotations of the same. That seems pretty simple. 😛

First thing one faces in robotics, is the motion update of the bot. This motion update requires the tracking of the number of rotation which when multiplied by the circumference of the wheel base gives the distance travelled. However, this approach is not for motion including turns 😛

Types of Rotary Encoders?

Generally, there are two types of rotary encoders: absolute and incremental. Read the rest of this entry

PyQt4: Getting into action

After a short tutorial, let’s make a “Serial Data Reader application”.
PROBLEM STATEMENT: The data has to be read from the serial port and to be displayed to a text box in the form.

SOLUTION: The first step of every solution is to make the Flow-Chart. The flow chart for this problem will be like this.


The first step is to open the serial port. This will use pyserial package which has to be imported to the script using this line. 😛
import serial

However if the package is missing then it can be downloaded from the Read the rest of this entry

PyQt4: Getting into depth

Now let us add some functionalities to the window generated. For that, I am listing the APIs to create any widget and handling signals & slots:

To create any widget:

1. textbox=QtGui.QTextBox(“content of the text box”)

Note:This will work fine unless until you need to access this textbox in some function treating it as a global variable. To avoid the errors in future, use this line:

self.textbox=QtGui.QTextBox(“content of the text box”)

adding self in beginning will make textbox an attribute of the window under which it is created.

2. self.label=QtGui.QLabel(“content of the label”)

3. self.pushbutton=QtGui.QPushButton(“text on pushbutton”)

to create singnals and slots:

This can be achieved in two ways:
1.New version API- QtCore.QObject.Connect method:
QtCore.QObject.Connect(<name of the object generating signal>,QtCore.SIGNAL(“<signal name>”), <slot>)


QtCore.QObject.Connect(self.pushbutton,QtCore.SIGNAL(“clicked()”),   self.on_pushbutton_click) Read the rest of this entry

PyQt4: Displaying Windows

While coding in PyQt, one should be little familiar with both the python language and Qt Gui programming.

How to write a minimal skeleton code:
First we have to add the following line to the script to avoid writing python for executing each script 😛

Thereafter all the necessary modules will have to be imported. sys is needed to initialise the QApplication. QApplication is a kind of parent application in which all the GUI components work. According to Qt documentation-

“The QApplication class manages the GUI application’s control flow and main settings. It contains the main event loop, where all events from the window system and other sources are processed and dispatched. It also handles the application’s initialization and finalization, and provides session management. It also handles most system-wide and application-wide settings. For any GUI application that uses Qt, there is precisely one QApplication object, no matter whether the application has 0, 1, 2 or more windows at any time.”

QtGui is needed here if we want to display widget. If no widget is to be displayed then this line can be dropped.

import sys
from PyQt4 import QtGui

The main() function in C is analogous to the following line in python:

if __name__==’__main__’:
# this will create an application named ‘a’initialised with a command-line parameter.

#application is executed.

Now if we want to display any widget or window, we have to write it between the above two lines.


Running the final code will display a Widget.


import sys
from PyQt4 import QtGui

if __name__==’__main__’:



Introduction to PyQt: light-weight cross-platform Solution for Qt

While i was getting handy with Qt, came the problem of porting the application to the other platforms. For me, the main aim while jumping in Qt application development is to make the application run on embedded boards like mini2440, Raspi etc. and this time the board was Raspberry Pi.
There was some UI based project to be ported to Raspi, which required the cross-compiling of whole QT IDE for the Raspi, and i got something called qtonpi. Which, i felt, would require some tedious long hours, which i didn’t have.
Probably you will get this in my next blog on Qt.
But for now, there was another option called (drums beat…) PyQt. 😛


Easy and light weight PyQt. it worked as magic. Almost every linux distribution has python installed and all you need is a PyQt dev-kit, which basically binds the Qt APIs to the python. It is really a light-weight package which can be easily installed in almost all linux-distros in all architectures.
Lets get started:

Setting the work environment and installations: 

The dev-kit can be found in synaptic manager or at terminal by typing:-

$sudo apt-get install pyqt4-dev-tools Read the rest of this entry

Serial Port Interfacing In Qt

Well, for an embedded system guy, serial port is one of the most popular way to make your PC communicate with a target board, be it SBC or some serial based automation sort of work. Now, challenge is to use your own serial terminal software 😛 Well that’s the least what can be expected from a Qt Application developer.

Gui for the application

So this post is all about building an application which opens a serial port, and communicate with it.  Read the rest of this entry

RF communication

During early days of mine as an electronic hobbyist, the wireless communication had always

Wired bot

got me excited . Afterall, who wouldnot grow tired of those tangling wires of wired bot. 😛 So i got the cheapest rf module available in the market, without knowing much about it. 😛

So this is a simple project for the beginners who are going to use rf modules for the first time. Here, the signals are generated by the user via push buttons and is sent to the receiver module kept at a distance.

Let us grasp some basic information on the working of a RF- module.

Rf modules

These RF modules work between 30Khz-300 Ghz. In our case, it’s frequency is around 400Mhz-500Mhz (434 MHz approaximately).  The digital data is represented as the variations in the amplitude of the carrier signal according to the message signal (known as ASK).It receives serial data and transmits it wirelessly through RF through its antenna. The transmission occurs at the rate of 1Kbps – 10Kbps.The transmitted data is received by an RF receiver operating at the same frequency as that of the transmitter.