Thursday, 20 August 2015

Control The Ball With Accelerometer

Android Game Development



                Hi Guys, Finally I m able to publish a much awaited game in android platform. This game took me 18 days and nights full on to realize. Of course I got help here and there. My roommate keshav Ladha is a newbie in this field. he gave me hand in designing graphics and and my ex teacher Mr. Sudipta Chatterjee helped in some coding. To tell you guys the truth the simple purpose of this project was to pass the time here in college. The college has been reopened after a two and a half months of leave and  the initial days of the college are filled with intro classes as well as the hullabaloo related to the newcomers' fresher's party, Independence Day Parade and all those stuffs. So i decided to take some time off from the college and dedicated myself in designing a new game. And two and half weeks of hard work finally paid. 
                To be honest, I would like to add here one certain thing. I was involved in embedded systems last to last semesters. I worked in various sensors. In making DIY (Do-It-Yourslef) projects, i used ultra sonic sensors and then some IR sensors. Again for another project I tried my hands on accelerometer but could not properly integrate my Arduino with it. The problem which i faced is that while you work on such sensors, you got to work on so many wires to attach that sometime the hardware cant be properly calibrated. Of course you can make certain good products but you got to work harder in case you don't use a simulator like Proteus or something. What I m trying to do here is I m advocating the importance of knowing how to interface smartphone with your development board like Arduino. Nowadays smartphones come equipped with almost all the sensors we know of. Few months back I wrote an article in this very blog about the smarthome application. That was my first step to learn how to interface a hardware (Arduino) and a software (Android).  Now in order to make this game, i have used accelerometer and with the asme procedure, we can use the smartphones sensor to make our DIY.

                 Coming back to our discussion on the game development, the game which I got published in Play store on the morning of my nation's 69th Independence Anniversay, i.e 15th August, 2015. This game, is about controlling a red ball using the accelerometer control of the phone and avoid its intersection with some given lines and take it to its destination, that is a grey circle. The game can be downloaded from the given link: 
https://play.google.com/store/apps/details?id=com.mayukh.mayukhchakraborty.controlball&hl=en. The code of this project is here,:
https://drive.google.com/file/d/0B-7SqmMCsRSObVE2U2tSQy1BTnM/view?usp=sharing







Saturday, 25 July 2015

Android Game Development: Tik Tak Toe

Get the app from Google Play Store: 

 https://play.google.com/store/apps/details?id=com.mayukh.tiktaktoe


            Hey Guys!! this is my new arena, and I am a bit perplexed about it. I have been working in android for a long time, but Game!!, this is surely a new thing to get your hands dirty. Let me tell you that Game Industry is one of the fastest growing industry in the world. For example take android for instance, out of every 25 apps in Android Play Store, 23 are game itself. This is probably because game is something which is very well played by a wide range of audience, and it is very much in compliance with small handset device you use. Quintessentially,  I travel mostly to and fro, between my college and my home in Guwahati. For those who knows about these places, bus journey between Silchar and Guwahati is like 10 to 12 hour long. So I have found myself as well as my co-passengers to engage in either music or gaming in small handsets. Games and music are the most common time pass of the world and that is one reason why these two industries are the most booming in current world. In this context, two major game development companies are worth mentioning. Imangi Studios, best known for the world famous Temple Run Series, and Rovio Entertainment best known for the Angry bird franchise. The husband-wife pair of the United States and worth applauding creator of Temple Run (Natalia Luckyanova and Keith Shepherd) and Finnish college trio of Rovio Entertainment (Niklas Hed, Jarno Väkeväinen, and Kim Dikert) are inspirations to millions of small time game developers.
                 Coming to my own game, this game is developed on android sdk. Not much of graphics has been used here. As a beginner, I tried my hands on canvas of android. Te tricks of the canvas can be used for many allusions you can create with simple codes. The codes for the game Tik Tak Toe can be downloaded from here: https://drive.google.com/file/d/0B-7SqmMCsRSObzAyUHozVFI3Yms/view?usp=sharing. 
                      Thanks Guys. You keep me motivated when you read my blog and send me valuable suggestions. This motivation will be immensely amplified if you guys rate and give review to my apps in play store. Thanks. 
                      
                      


           

Friday, 12 June 2015


 Arduino based Android Smartphone controlled DC Appliances


 Hey folks, I haven't been writing for a long time. I guess, a learner like me takes his time to learn things and then apply in its proper place. The last four to five months were wonderful, because I got to learn working on Android. Since I am a hardware man, I tried in my own way an integration of android and hardware, and guess what, the first thing that would probably hit is a “Home Automation” application.
Now, what is a Home Automation ? Well, other sobriquet of home automation is “Smart Home”. Today, almost more than half the population of earth uses smart phones, and the number is increasing day by day. These small hand held device is used not only to contact people but surf the net, do office work and entertainment. So day by day, our dependency on these devices are increasing and I say it is for a greater good, because these devices are portable and we keep it with us most of the time. What, if we could control our home appliances like lights and fans with these devices too. I found that we could actually by integrating these devices with hardware. We can always always design an embedded systems with the help of microcontroller and get it communicate with deevices like a bluetooth modem. Our smart phones have inbuilt bluetooth sockets and we can make use of some of the apps which can send data over the bluetooth and thus with the help of the given data we can control the lights fans we have designed in our embedded systems.
The application I have designed is shared here and also right now been published in the play store. My worthy collegue Chaman Jain and my teacher Sudipta Chatterjee has
helped me a lot and time to time has given me required motivation to designed this whole project. First I will let you know how to make the the circuit of the control systems I have designed.


Things you gonna need:
a. Arduino Mega (Development Board)
b. Bluetooth Modem (HC-05)
  1. An RGB LED.
    d. A DC fan
    e. A Breadboard along with some hook up wires
    f. an Android powered smart phone (Android 4.0 or above)


    So below is the circuit diagram. I have used a common cathod RGB LED, if you want you can use a common anode LED too. No issue as such on the choice of the LED.

      




The GND pins of the RGB LED, DC fan and the bluetooth modem is connected to the ground. The positive pin of the DC fan is connected to the pin 8 of the arduino. Red pin of the RGB is connected to pin 9, green to pin 10 and blue to pin 11. The RX pin of the bluetooth modem is connected to pin 15 (TX1 of Arduino Mega) and similarly TX pin is connected to pin 16 (RX1 of Arduino Mega). 


This app is now published in Play store, get it from the following URL:

Tuesday, 11 November 2014

Protect your home with Arduino based LPG leakage detection module

MQ-6 LPG gas sensor project


          Hi, guys. It is been quite a long time I have not blogged. The Tecnoesis fever in National Institute of Technology, Silchar had been very high for these few weeks and I too can't separate myself from it. I too took part in it. There is an exhibition called "Evolution" which has been conducted for last three years in our college and this year I was able to take part in it. I, in a way represented the robotics club of our college in the exhibition and two of my projects were submitted in it. Thanks to Mr. Saurav Sen, the organiser of the exhibition, it was a grand success, with lot of enthusiastic participants and viewer. Even Doordarshan visited the college to cover up our technical festival and in a way the exhibition also came under focus. You might be wondering what exactly was this exhibition all about. Well, this exhibition " Evolution" is a platform to show cast the talent of the students in the field of product development, software designing and display of some of technical development in the world of science and innovation
          Well what I m gonna tell you here is that one of the display of my project in the event was the LPG gas leakage checking system. LPG leakage is a major concern in metropolis, especially the high rise buildings where the fire breaking can cause damage to property and also causes risks to life, as might have happened in many places. With this small product you can basically protect the house. This small stuff is called the LPG gas leakage alarm system and unlike most of the smoke detector based alarm system which is triggered by the advent of smoke due to some fire, this particular gas detector will help you before even there is a chance of catching the fire. Just because this small prototype I have designed can actually detect the rise of concentration of LPG in surrounding atmosphere. This particular gas sensor so called MQ-6 gas sensor which is just one of the gas sensor in the MQ series, is meant to detect propane and iso-butane, which are the chief constituents of the LPG gas cylinders. So the internally the MQ-6 is like it has a variable resistance inside it which becomes low in case we get to a high concentration of the aforesaid two gases. So the chang in the current can be used as a signal to trigger the alarm. But instead what I have done is used a microcontroller board, my favourite, Arduino duemilanove, to interface the MQ-6 gas sensor with arduino and a buzzer. So whenever I get a high concentration of LPG I get an alarm triggered till the concentration is not low.
         So what exactly you have to do is buy one MQ-6 gas sensor, and if possible the product comes embedded on a PCB which is easier to use. As you can see in the video the gas sensor I m using is already calibrated, all you got to do is use its four pins, AOUT, GND, VCC and DOUT to the required pins on board.  AOUT goes into some analog pin, Dout goes to the ground via a 10 k resistor. VCC as usual 5 V and GND to the ground. 
                                 
                                                                                                                
             But in case you don't have the board, you guys don't have to worry since the even with the sensor you guys can make a way out for it. Below is the picture of the gas sensor and the pin diagram.                    

         All you have to do is connect all the two A pins and two B pins and then, one ground pin is connected to ground, the A pins along with the VCC pin to the 5 volts and the H pin to ground via a 10 K resistor and one pin left to the analog pin on the arduino board. Now all that is left is to write the program in Arduino IDE. So here I share my first code on a project that can be practically implemented

        Below I have attached the videos. You can check them out too. 


int sensorInput;                         
int buzz = 8;

void setup()
{
  Serial.begin (9600);
  pinMode (buzz, OUTPUT);
}

void loop()
{
  noTone (buzz);                        
  sensorInput = analogRead (A0);            // reading the analog data from the sensor
  
  if (sensorInput >= 200)                   // If the data is above 200, it triggers the alarm
  {
    tone (buzz, 1000);
    delay (500);
    tone (buzz, 3000);
  }
  else
  {                                               // Else no alarm
      noTone(buzz); 
  }
 
  Serial.println (sensorInput);
  Serial.print ("  ");

                     







     

Friday, 31 October 2014

Play With Buzzers

Arduino Based buzzer projects

     Components Required:     1. Arduino Board

                                                  2. One crystal 27c 313


     The buzzers so called crystal buzzers to are fascinating in a sense they can be used in various projects like the projects having the requirement of sound system, like say some alarm system or so. Since I m a so called maverick in my approach I wanted to do my first experiment on buzzer with some out of the box techniques. So I happen to pick up one of the buzzer I bought from Guwahati during the last diwali holidays and I started to look into the possibilities of using it with my arduino duemilanove. Interestingly in arduino's standard library we can access some functions which are meant to be used for speakers. Cool enough you can set the frequencies of yopur choice while using it. So it came to my mind why cant we use it to play the notes of classical Indian music, Sa Re Ga Ma Pa Dha Ni Sa (as Do Re Mi Fa So La Ti in English).
       Well, guys, I m not so good in music though. While I was in 2nd grade, my mom tried her best to teach me tabla, an indian instrument which you can associate with Ustad Zakir Hussain. I screwed it up badly. Well, so I guess if my mom gonna see this post I m quite sure she will go goosebumps for the first time. 
        Well, so what I did, is I googled about the frequencies of the notes mentioned about. As the seniors of our college taught me, that google is your best friend. Use it to advantage. And indeed here, for this project itself, google quintessentially acted like my best friend. Just google "sa re ga ma frequencies" and in the first page of the search result you will get the frequencies of the notes So what was left was just to use in it my code. So here I m. 
          And as you can see that I have used the arduino's serial monitor to feed my command and play sa re ga ma pa. But if you have an eight key keypad, you can make a personalised piano with it. So guys just check out the code below and make your own pianos. 

int buzzer = 8;
char tune;

void setup()
{
  Serial.begin(9600);             // Setting up baud rate. We keeep the standard to be 9600
  pinMode(buzzer, OUTPUT);     
}

void loop()
{
  if(Serial.available() > 0)             // Checking for the buffer for input value
  {
    tune = Serial.read();                 // Reading one character command from the buffer
    
    if(tune == 'a')                      // here is the play. All the note of Sa re ga ma has some frequencies
    {                                    // I have used some of them after some search in google
      tone(buzzer,240);                  // Sa: 240 hz
      delay(1000);
      noTone(buzzer);      
    }
    if(tune == 's')                      // Re: 270 Hz
    {
      tone(buzzer,270);
      delay(1000);
      noTone(buzzer);      
    }
    if(tune == 'd')                       // Ga; 300Hz
    {
      tone(buzzer,300);
      delay(1000);
      noTone(buzzer);      
    }
    if(tune == 'f')                       // Ma: 320 Hz
    {
      tone(buzzer,320);
      delay(1000);
      noTone(buzzer);      
    }
    if(tune == 'g')                        // Pa: 360 Hz
    {
      tone(buzzer,360);
      delay(1000);
      noTone(buzzer);      
    }
    if(tune == 'h')                        // Dha: 400 Hz
    {
      tone(buzzer,400);
      delay(1000);
      noTone(buzzer);      
    }
    if(tune == 'j')                       // Ni: 450 Hz
    {
      tone(buzzer,450);
      delay(1000);
      noTone(buzzer);      
    }
    if(tune == 'k')
    {
      tone(buzzer,240);
      delay(1000);
      noTone(buzzer);      
    }
  
    Serial.print(tune);                         // printing command
    Serial.print(" ");
  }

}

  
 
    
       And guys it will be totally unjustified if I don't mention here that I didn't make these videos. My friend Prashant Maroti, who not only gives me his valuable suggestions and ideas to proceed with my work but also helps me with my projects, has made this videos of the buzzer systems I have designed. An amazing personality he is.

Monday, 27 October 2014

Creating A Command prompt In Arduino

Using an Arduino for turning on and off an LED is not a very big deal, I guess. But how about this:
You are basically telling your microcontroller to plain English statements to turn the green led on, turn the blue led on and so on. For it you simply require to know some few functions available in the arduino development environment. It is really cool. I personally believe that this is more futuristic than just commanding your arduino board with just a key on your keyboard. In real life we use command prompt in our desktop computers to workout our stuffs and there we use meaningful english commands like print run etc to make things work. people dont want a robot who has been design to raise his hands when say some number in the num [pad is pressed. Instead you might find your bot more humanistic if it works on commands like "Raise_Left_Hand". That sounds more mature from.automation point of view. So here is a small code for the arduino developers who wants a personalised small command prompt. This small code is just a quintessance of a bigger picture I just talked about. 
You basically require a breadboard, two leds, one green, one blue, some hook up wires and an arduino. 

int ledGreen = 7;            
int ledBlue = 8;

void setup()
{
  Serial.begin(9600);             // Setting up baud rate. We keeep the standard to be 9600
  pinMode(ledGreen, OUTPUT);      // LED Green pin set to output
  pinMode(ledBlue, OUTPUT);      // LED Blue pin set to output
}

void loop()
{
  if(Serial.available() > 0)             // Checking for the buffer for input value
  {
    String command;                      // Creating a string variuable
    while(Serial.available() > 0)         // creating a while loop for reading buffer
    {
      command += char(Serial.read());    // creating the string   
      delay(250);
      
      if (command == "GREEN_ON")              // Creting condition
      {
        digitalWrite(ledGreen, HIGH);
      }
      if (command == "GREEN_OFF")
      {
        digitalWrite(ledGreen, LOW);
      }
      if (command == "BLUE_ON")
      {
        digitalWrite(ledBlue, HIGH);
      }
      if (command == "BLUE_OFF")
      {
        digitalWrite(ledBlue, LOW);
      }
    }
  
  Serial.print(command);                         // printing command
  }
}




Monday, 29 September 2014

        Ultrasonic Sensor projects based onArduino

                  Development Board: Arduino Duemilanove

                   Microcontroller:      ATmega 328

                 Ultrasonic Sensor:     HC-SR 04



            Guys, I happen to get involve myself in college Robotics Event and eventually start doing some hobbyist stuffs in my room. During the first year in my college, NIT Silchar I happen to do just minor manual robotics stuff like connecting wires and rotating motors using Doble Pole Double Throw (DPDT) switches, and rotating wheels and eventually making four wheeled robots and moving it in the path of desired path with the famous differential drive concepts. Well, representing the college in IIT Kharagpur was like a dream come true. The manual bot we designed was cool and we did great.
              My second year in college I got involve in autonomous stuff, and i started digging into sensors and microcontrollers. I did a small summer training from a reputed company in Guwahati, India on embedded systems and learnt to work on pic microcontrollers. Coming back to college I started working in Arduino because when i saw some sample projects in the Arduino's official site arduino.cc, I found the codes a bit simpler than the embedded C I learnt in Guwahati.
                   So guys, this was the first project I did in college related to embedded system. I second year I was chosen the Co-ordinator of the Robotics Club of our college, and thus I happen to oganise the first ever Robotics Event in the college.  So this small Ultrasonic sensor based module was also displayed in it.
                      The stuff is like, there is one ultrasonic sensor, which works on the principle of bat's navigation technique. The Ultrasonic sensor, HC-SR04 has two eyes. one is the trigger eye, which emits the ultrasonic sound of 40kHz. if an obstacle comes in the range of 2 cm to 450 cm, it is detected by the echo generated by it. The echo eye on recieving an echo generates a digital impulse. So we calculate the time elapse between the emittion of the sound to the receiving of the echo or more precisely the generation of digital impulse. The arduino codes are given below:

  this code is designed so as to demonstrate the ultrasonic sensor and its uses. the code is deviced as of, the distances of the obstacle is measured by the LEDs glowing.


int trig = 1;            
int echo = 2;
int ledRed = 4;                    
int ledGreen = 5;
int ledYellow = 6;
int ledBlue = 7;

void setup()
{
  Serial.begin (9600);
  pinMode(trig, OUTPUT);            // Configuring digital pin 1 as output
  pinMode(echo, INPUT);             // Configuring digital pin 2 as input
  pinMode(ledRed, OUTPUT);          // Configuring digital pin 4 as output
  pinMode(ledGreen, OUTPUT);        // Configuring digital pin 5 as output
  pinMode(ledYellow, OUTPUT);       // Configuring digital pin 6 as output
  pinMode(ledBlue, OUTPUT);         // Configuring digital pin 7 as output
 
}

void loop()
{
  int tym, cm;
  digitalWrite(trig, LOW);      // trigger remailns OFF for 2 microsecomds
  delayMicroseconds(2);
  digitalWrite(trig, HIGH);     // trigger remains ON for 10 microseconds
  delayMicroseconds(10);
  digitalWrite(trig, LOW);    
 
  Serial.print(" ");             // random delay
 
  tym = pulseIn(echo, HIGH);     // this is the time processor calculates since the time the last line of the code is executed
                                  // this is basically the time elapsed between the transmission of Ultrasonic sound and recieving of its echo
  cm = tym/2 / 29.1;             // distance using the time
 
  if(cm == 0)
  {
    Serial.print(cm);                           // If the obstacle is not detected, within a range of 4.5 meters, No echo is recieved.
    delay(20);                                  // Hence the time is taken to be NULL or )
    digitalWrite(ledRed, LOW);                  // And hence the distance calculated is also NULL
    digitalWrite(ledGreen, LOW);
    digitalWrite(ledYellow, LOW);                // this statement is a must.
    digitalWrite(ledBlue, LOW);                  // here in this situation all the LEDS are in OFF state
  }
 
  if(cm > 0 && cm <= 10)
  {
    Serial.print( cm );
    delay(20);
    digitalWrite(ledRed, HIGH);                      // If the obstacle detected is in the range of 0 to 10 cm
    digitalWrite(ledGreen, LOW);                      // Red LED glows
    digitalWrite(ledYellow, LOW);
    digitalWrite(ledBlue, LOW);
  }
 
  if(cm > 10 && cm <= 20)
  {
    Serial.print( cm );                                // If the object detected is in the range of 10 to 20 cm
    delay(20);                                         // Green LED glows
    digitalWrite(ledRed, LOW);
    digitalWrite(ledGreen, HIGH);
    digitalWrite(ledYellow, LOW);
    digitalWrite(ledBlue, LOW);
  }
 
  if(cm > 20 && cm <=30)
  {
    Serial.print( cm );
    delay(20);
    digitalWrite(ledRed, LOW);                         // if the obstacle is in the range of 20 to 30 cm
    digitalWrite(ledGreen, LOW);                       // yellow LED glows
    digitalWrite(ledYellow, HIGH);
    digitalWrite(ledBlue, LOW);
  }
 
  if(cm > 30 && cm <= 40)
  {
    Serial.print ( cm );
    delay(20);                                       // If the obstacle is in the range of 30 to 40 cms
    digitalWrite(ledRed, LOW);                        // Blue LED glows
    digitalWrite(ledGreen, LOW);
    digitalWrite(ledYellow, LOW);
    digitalWrite(ledBlue, HIGH);
  }
 delay(20);
}