Sunday, 11 December 2016

Automatic Hashtag Maker for Newsbot

Newsbot is a twitter-bot which tweets news headlines from various verified news sources. To increase its reach and engagement I had created a rudimentary version of an auto-hashtag maker. The algorithm is very basic. It just crawls the URL of the article and filters out the stop words (Eg: to,an,a,the..). It then analyses and sorts the words based on their density. It then compares these words with the once already in the headlines and if there is any match, it uses the matched word as the hashtag. Nothing fancy. It did its job of increasing the views per tweet and added some followers too but most of the hashtags were totally hilarious.

As you can see above, the hashtags were not at all informative. But sometimes this method did give an average hashtag...
And sometimes pretty good ones too...
As this algorithm does not take into account the importance of words in shaping the meaning of a sentence, it doesn't make powerful hashtags. 

The 2nd version, which the Newsbot now uses, utilizes Brill Tagger to analyze parts of speech. The first step is isolating proper nouns and common nouns. Proper nouns are given more importance as they may point towards a personality or a place. If there are no proper nouns in the sentence, then the script manipulates the common nouns to produce meaningful hashtags. This algorithm is still under testing. You can view the tweets and share your views, I will try to make the necessary changes.  It is still a work in progress and once its complete I will share the code. 

Wednesday, 9 November 2016

Saturday, 25 June 2016

Photon: A Simple Analog Line Follower

The robots that I build do not stay for long as I dismantle them and use their parts to build other
projects. Actually I do that to save money and whenever my friends ask me to show some of my robots, I am left with nothing. So I decided to build a permanent robot that I can show to my friends and relatives if they ask me to do so. I wanted to keep the robot as cheap and simple as possible so as to not hamper other projects. I decided to build a simple line follower as line followers, though simple, are very entertaining to watch.


Photon had to be cheap so I decided to use LDRs and LEDs to build a line sensor. The principle behind its working is very cheap, white reflects light whereas black not so much. I used white LEDs to allow Photon to follow any colored line on a contrasting surface. 


I used geared motors in Photon because they are cheap, provide sufficient torque and draw sufficiently small amounts of current under load.


I had to keep the main circuit cheap so I decided to use a voltage comparator as they are accurate compared to transistors and can operate at variety of voltages. I used 2 TIP122 transistors as motor drivers. I also added 2 potentiometers to control the sensitivity of the sensors. This allows photon to travel on a wide range of tracks with contrasting colors. 

Power Supply

At present I am using a 9 volt battery to power photon but I will upgrade to a rechargeable Ni-Mh battery pretty soon.

I am still working on the chassis. I want the chassis to be small and light. I am trying to modify old lunch boxes and sweet boxes but I have not yet found a perfect case. I have spent about Rs.220 
(close to $3) on photon so far as I already had the motors. With the motors photon will still cost less than Rs.500 (close $7). Ni-Mh battery may add to the cost a little but it will be a one-time investment.

How does the Movie Search Engine work?

Recently I put together a Movie Search Engine that has built-in Sentiment Analysis that reads the reviews for the movie and gives the rating accordingly. The rating also takes in some other factors. Its built using php. It was just a fun project and was very quick to build because of some excellent APIs.

The site uses the TMDB API for the posters and OMDB API to get the IMDB ID and the user rating. I used a web scraping to collect user reviews from IMDB using the collected ID. If a movie is searched for the first time on the search engine, it stores its details locally on the server to decrease the load time when the movie is searched for again.

The disadvantage of using 2 different APIs for searching a single movie is that sometimes the poster and the movie doesn't match, but I had to use both the APIs as the OMDB API doesn't allow poster access for free. IMDB doesn't allow its poster to be used.

For the sentiment analysis I used the PhpInsight Library. It was very easy to work with and pretty good given the ease.

Do check out the website and give me your suggestions. (I couldn't find a good name for it. You are welcome to try!)

Friday, 27 May 2016

Choosing a battery for your robot

One of most difficult things that you may face while building a robot is not just the circuit or the program or the mechanics but the power-source. You would want to invest on a reliable power-source that you can use for a long time in a number of projects. I personally dealt with this difficulty a lot of times and in some cases I had to stop the entire project midway due to the lack of a good power-source.

Always look out for these 2 things while selecting a battery:-
1. The capacity (Usually given in mAh) - If a battery as 2200 mAh capacity it means the battery has the ability to deliver 2200 mA (2.2 A) for an hour. (This figure is not always accurate and is mostly observed only under laboratory conditions.)
2. Voltage - Voltage determines how well the battery can push the robot (symbolically and not to be taken seriously). Higher voltage means the battery will be able to deliver the current more easily against resistance.
Alkaline batteries


Alkaline batteries are the most abundant and easy to find. They are cheap as well which makes them ideal for simple robots and for testing, though for a long period of time these may end up costing a lot
due to the constant need for replacements.


NiMh battery
MiMh batteries are what I prefer as they are fairly cheap compared to LiPo but still provide the ability to recharge along with a high capacity. The only drawback is that they discharge even when not in use thus they cannot hold the charge for long. 

LiPo battery


LiPo batteries are the best if you do not consider their price. They are light weight, have high energy density and can be recharged hundreds of times. These are good for almost all types of robots. These batteries are usually found in mobile phones and laptops.


Li-ion battery
These batteries have a light weight while maintaining the high energy density. These are suitable for robots that have medium to low energy demands. These are comparatively cheaper than LiPo and provide great alternative. 

Lead Acid

Lead acid batteries are unbeatable when it comes to delivering high power at low cost.  These batteries are generally used in robots that have a high energy demand like combat robots. Lead acid batteries are used in vehicles.

There are other types of batteries like NiCd but try to avoid them as NiCd type batteries have something called memory effect i.e. they lose some of their capacity if you charge them before they drain completely.

All robots are not built equally. Some robots are built for combat and high power work like sumo robots while some have lots of sensors and processing equipments while others are simple like line or light followers and their energy requirements vary accordingly. Let's look at an example:-

Let us assume that you have built a robot which has 2 motors, a microcontroller (say an Arduino) and some sensors. The motors require atleast 6V each for efficient performance and draw a current of 200 mA under load. The microcontroller and the sensors together draw about 200 mA (just an assumption). The total current requirement for the entire robot is 200 mA + 200 mA = 400 mA. Now you chose to power the robot using four 1.5V NiMh batteries each having a capacity of about 2000 mAh. Based of the current requirements, your robot will last for about 5 hours (2000 mAh/400 mA)

Thursday, 5 May 2016

Jarvis: An Arduino Based Home Automation System

I was inspired by Jarvis from the Iron Man and strongly wanted a home automation system. The existing systems were not cheap so I decided to build my own home automation system using an Arduino. At present its functionality is limited to switching the devices on or off but it can process natural language at a very basic level that allows you to use this technique to incorporate natural language processing capabilities into other Arduino projects.
CAUTION: I DID NOT test this project with real world appliances and if you are planning to do so, do it at your own risk. I strongly advice a professional electrician's help in doing so.
The project is fairly simple in terms of the things required.
  1. Arduino
  2. Bluetooth Module (Preferably HC-05)
  3. LEDs (For prototyping) x 4
  4. BC-547 transistors x 4
  5. 10k and 150 ohms resistors x 4 each
  6. Relay Board (Optional, only if you are serious about installing Jarvis in your home)
  7. Power supply (I used a powerbank and a 9V battery)
  8. Wires and Breadboard
  9. An Android phone or tablet with an Internet connection

The main problem that I faced while developing this project was processing the input using the Arduino to understand what the user has said. The user, by default, can carry out 2 functions: to switch on or switch off a device. The code by default supports 4 devices but it can be extended. The program basically finds the keywords "on" or "off" and the names of the devices in the sentence and executes that function. You can control up to 2 devices simultaneously( a combination of "on" and "off" or each device). I used this method because it allows you to say anything as long as the sentence contains the keywords. For example you could simply say "Switch on all the lights" or even "OK buddy, do me a favor turn on all the lights" and both these sentences will have the same effect, i.e they will switch on the lights. I used the Arduino functionstring.indexOf("value") to locate the keywords in the sentence. I have included the circuit diagram for connecting the LEDs. It is not recommended to connect all 4 LEDs directly to the Arduino as its output is not powerful enough to drive all 4 at once. Do check the datasheet of the transistor to know the pin configurations as sometimes they differ from one manufacturer to another. The pins on the Arduino are as follows:
Led 1 (Corresponding to light) = 13
Led 2 (Corresponding to fan) = 12
Led 3 (Corresponding to TV) = 8
Led 4 (Corresponding to charger) = 4
Here light, fan, television, charger are the keywords required to trigger those pins.
The code was written in hurry so I did not comment or make the code easier to understand. I will make the code more efficient and neat as soon as I get some time. Any volunteers would be great!


    Integrating speech recognition into this project was one of my main motives from the beginning and what better way then using the powerful speech to text engine on Android? I used MIT app inventor to build the app. The app is fairly simple. What it does is it takes the speech input, converts it into a string and sends it to the Arduino via Bluetooth.
    Though the initial setup works good but one has to open the app to give commands and this can be a little boring if you end up using Jarvis pretty often. I modified the initial Jarvis app to start listening as soon as it is opened. Then I used Tasker and Commandr to create a custom voice command to open Jarvis. You can assign the call button on a Bluetooth headset or earphone to open Google now. Now as soon as you say your custom command the app will open and start listening!

    Jarvis is pretty simple to use. It has a pretty basic natural language processing capabilities that at least allows you to modify the sentence a little and thus eliminating the need to remember the perfect command. Jarvis allows you to control upto 2 devices simultaneously with separate on and off control or upto 4 devices with just a single control (i.e either on or off). The default keywords are fan, charger, television (or just TV), light (or lights).
    Example Commands:
    1.Turn on the fan please.
    2. Switch on the charger and turn off the lights.
    3. Can you please turn on the tv? I am feeling bored.
    4. Turn off everything
    The commands can be used in any combination. The only thing to remember is the presence of an on and/or off keyword and the name of the device/s. 

    Saturday, 28 November 2015

    Arduino logobot

    I had built a simple robot whose movements can be programmed through four switches a long time ago. I had recently written about it on instructables.

    Picture of Arduino logobot
    Hello there! When Arduino released its robot I was particularly fascinated by the logobot sketch. I thought, logobot could be used to teach children about robotics and programming and they would also have a lot of fun with the robot. So I decided to build my own version of the logobot.

    Step 1: Materials

    Picture of Materials
    This build requires:
    1. Arduino
    2. L293D motor driver (You can also use a shield but you may have to tweak the code a little)
    3. 5 pushbuttons
    4. Perfboard / Breadboard
    5. Motors and wheels (You can also get a ready-made chassis that can be really helpful)
    6. Wires
    7. 2 x 9 v batteries (one for Arduino and one for the motors)

    Step 2: Switches and Circuit

    Picture of Switches and Circuit
    Connect the switches according to the circuit diagram. Use the 5v power supply from the Arduino to power the switches. Next connect the motors to the motor driver. The terminals will be labelled. Do not forget to connect the enable pins to a positive voltage. You can connect the enable pins to the battery powering the motors or the 5v power supply from the Arduino. I would go with the first one.

    Step 3: Programming the Arduino

    Picture of Programming the Arduino
    Download the Arduino code and upload it to the Arduino. Make sure that you have made all the necessary connections before testing the robot. For the first time, connect the Arduino to the computer and use the Serial Monitor to debug if the robot doesn't work. If the robot works as it should, use an external power supply for the Arduino.

    Step 4: How it works?

    Picture of How it works?
    The program is simple. Each key press is assigned a unique number and every time a particular key is pressed, the corresponding number is stored in an array. When the execute button is pressed the array is read and the numbers are converted into corresponding movements. Feel free to comment and ask doubts.

    Saturday, 31 October 2015

    Privacy 101: Protection against phishing

    Most of the interactions of people nowadays take place online. Perhaps the people you know on the internet might know more about you than people you know in person. This has led to the rise of privacy invasions and it is rising continuously everyday with the increase in computing power and the increase in the number of people who have internet access. Protecting yourself from privacy invasions was never more important than now. This series is going to mainly concentrate on educating people, especially non-techie people, about online frauds and threats and their counter measures.
    There are three main ways in which a hacker can find your password and log into your social media accounts such as google+ or facebook or use your identity for some malicious purposes. Today we will look at one of them, that is, phishing.
    Phishing is one of the easiest ways to know your user id and password. What a hacker essentially does is he clones the login page of the web service of which he wants your user id and password.
    1. He goes to the website.
    In this case

    2. Copies the source code and changes
    to his own login handle which can capture your username and password.
    Facebook source code

    3. Uploads the edited source code with some additional files to a server and sends a link to the page by spoofing an email address which looks exactly like the original and seems to have come from the original website.

    Counter measures:
    1. Make sure that the website you are redirected to is a legitimate one by checking the URL. Normally social networking sites and other sites that may include sensitive user data have an https connection. 
    2. Never login through an open Wi-fi as it is highly vulnerable to Man-in-the-Middle type of attack, which we will discuss later, where the hacker can actually see what you are browsing and typing.
    3. If possible check the source-code of the website for any malicious URL redirects.
    4. Set up two step verification on google+ or set facebook to send you an sms when a login takes place into your account. 

    The methods that are mentioned in this series or are going to be mentioned are for education and protection purposes only. I do not claim responsibility for use of any of these methods for illegal activities.

    Sunday, 22 March 2015

    How a computer starts: Behind the scenes

    We all use computers pretty much everyday, but have you ever wondered what happens when you switch on a computer. Let us go behind the scenes and find out what happens inside the computer.

    The BIOS chip
    First of all the CPU performs a procedure called "booting" when the PC is turned on. The instructions for this come from BIOS(basic input/output system), a program stored on a flash memory chip (BIOS chip). Under booting the PC first performs POST (Power-on self-test). POST is a small program contained in the BIOS that checks for hardware failures. When the test is successful, the BIOS then locates the bootable drive to load the boot sector. The execution is then transferred to boot-loader (a computer program that loads an operating system) located in the boot sector. 

    Booting is of 2 types: Warm and cold.

    Warm booting: This booting takes place when a PC restarts. In this case the system does not start from the initial state, hence the diagnostic tests need not be carried out. This type of booting is often carried out when a program crashes.

    Cold booting: This type of booting takes place when the system starts from the initial state, that is when it is switched on. Here the diagnostic tests are carried out. 

    This post was designed to give an introductory info on PC booting. For more information check this out.