Friday, June 12, 2015

Mobile Game Controller Using Python

This post is to show how to communicate between mobile and computer, and its one such project that combines a lot of stuffs from Wifi commmunication to keyboard user input. This is can be achieved through python and kivy and along with some other packages. When I surfed the net I saw people doing some gesture controlled powerpoint presentation which involves an accelerometer.I thought of doing something with the accelerometer not just for controlling presentations but for controlling games. Since I did not have an accelerometer I used my phone's accelerometer to control the game.I designed an app using kivy which collects the phone's accelerometer data and sends it to the computer, the computer processes the information received and generates key input events
If you would like to know how to use your mobile's accelerometer and transfer its data to your computer you can read this.

Lets move on. !!

First of all this project requires:

  • Python 2.7 in your computer.
  • QPython on your mobile or you can package the app and intsall it in your mobile. I just directly coded in my mobile itself.
  • Win32api for your computer 
  • For simplicity download PyUserInput
  • And finally a mobile having an accelerometer
Link for Downloading Python 2.7.

Link for Downloading Win32api. Download the one that suits your python version if it displays an error message during installation then you have downloaded the wrong version.
I used Kivy for creating the app. My friend Raamakrishnan created a windows phone app for the same. Refer the link below to for the code..

The app looks like this:



The code has been posted in the github 
#IIEE

Tuesday, June 2, 2015

Interfacing Arduino using Python

We know that Arduino IDE has inbuilt serial monitor. Using this serial monitor we can communicate with arduino and make arduino behave as we wanted. This serial monitor can be even built using python. This post is to show how to install PySerial and use it with arduino.

First of all download Python and install it (Python 2.7 recommended).

Python 2.7 Download

 Just by installing Python we cannot start programming. A script editor is also needed. There is a list of script editors available here. I use Geany.

List of Script Editors Python

The next step is to download Pyserial and  install it.

Pyserial Download

Download the tar.gz file and extract it. Then open the command prompt try typing python if you get a error message then follow these steps.

  • Right click Computer-Properties
  • Click change settings on the right hand side
  • Go to Advanced tab. Click Environment variables.
  • Double click Path and after a semicolon specify the path where python is installed
                       
  • Now restart the computer for the settings to get applied.
  • After restarting, open the command prompt and try typing python
  • Python terminal should open.
  • Now go to the extracted folder in the command prompt and type 
                                      python setup.py install

Installation will take place...

Now lets write a code to demonstrate the working of Pyserial.
This program switches ON and OFF the inbuilt led on the Arduino board.

Python Code:
 import serial  
 ser=serial.Serial("COM31",9600)   #start a serial connection  
 a='0'  
 while a=='1' or a=='0':  
      a=raw_input()               #get the input  
      if a=='1' or a=='0':  
           ser.write(a)             #write to serial  
           print ser.readline()       #read a line from the serial  
      else:  
           break  


Arduino code:

  #include<Serial.h>  
    void setup()  
    {  
     Serial.begin(9600);  
     pinMode(13,OUTPUT);  
    }  
    char a;  
    void loop()  
    {  
     if(Serial.available())  
     {  
      a=Serial.read();  
      if(a=='1')  
      {  
       digitalWrite(13,HIGH);  
       Serial.write("ON\n");  
      }  
      else if(a=='0')  
      {  
       digitalWrite(13,LOW);  
       Serial.write("OFF\n");  
      }  
     }  
    }  
  

The result will look like this:



#IIE

Sunday, May 24, 2015

World's First 9$ Computer named CHIP


C.H.I.P a tiny computer by Next Thing Co. It comes with a 1Ghz processor, 512 mb RAM and 4gb of storage. It has built in Wi-fi and Bluetooth and can be used to connect to things wirelessly. C.H.I.P comes with an open source operating system and has thousands of apps built for it. LibreOffice, Chromium browser, Torrent and lots more. It even runs Linux and is capable of handling full GUI as it handles other hardware attached to it. Pocket Chip an open source hardware which can be used with C.H.I.P. The pocket Chip has a 4.3" inches touch screen with QWERTY keyboard. It even has GPIO breakouts which makes it easy to connect to other hardware devices using PocketChip. It mostly does all computer sort of things. The company says that it will be available for everyone in early next year. It is considered as a rival for most developed manufacturers like Raspberry pi.#IIEE

Saturday, April 18, 2015

Line Following robot

This was my first project which I did after I entered college. It was done by me and my friend Raamakrishnan for our college tech fest. We used PID algorithm for the bot. We had our bot working perfectly but the track had small turns and our bot's length was bigger than the turn. We were unable to do anything so we withdrew from the competition. But I am proud to say that I competed with seniors. I don't have any photos or videos to share with you. One thing I learned is that things would seem simple when you look from outside but when you go into it you have to face a lot of difficulties but I still hope that things are always easy.