Sunday, 21 June 2015

Alcohol sensor (MQ3) interfacing..¡¡¡

Heyyy..now am here to explain the "interfacing of alcohol sensor to popular ARDUINO. It's very easy.
Alcohol sensor simply mq3 sensor is analog sensor which outputs the voltage.o/p of the sensor is fed to analog pin of ARDUINO..
Here Is the pic how the sensor looks
It contains six pins so we to work for sometime to make this six pins as three pins i.e VCC,GND,Vout.below fig shows how to connect this sensor To ARDUINO board




Now we have 3 pins for the sensor,connect VCC to 5V,GND to GND pin of ARDUINO and data to any analog pin of arduino
Just dump the below Sketch to ur board and observe the output of the sensor in serial moniter

Here is the code
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
  Serial.println(voltage);
}

So final conclusion is that we can this sensor for breath analyzer ,automatic ignition off in cars etc..i hope u understand.
Thank you 



If u have any queries ping me at facebook.com/winrap57

Making your own arduino...!!!

Hiiiii...
   Now we are going build a arduino board..before knowing this WHAT IS ARDUINO..??? it a combination of some hardware (say microcontroller)along with compatible software(ARDUINO Ide)
Above pic shows the basic ARDUINO board with atmega328p as its heart.so,now in this post I will tell u how to make your own board.for doing this you should require
Atmega328p ic with base
16 MHZ crystal oscillator
22pf capacitors
7805
Male headers etc....
 If you buy a atmega328p,initially it is not ARDUINO Ide compatible microcontroller. So to make it a ARDUINO compatible mc you must burnboot loader to that ic..it's very easy and simple procedure for that process is explained below
 To burn bootloder u must have an ARDUINO board and breadboard with required components. ARDUINO to breadboard connections is shown in below pic


Burning the Bootloader

If you have a new ATmega328 (or ATmega168), you'll need to burn the bootloader onto it. You can do this using an Arduino board as an in-system program (ISP). If the microcontroller already has the bootloader on it (e.g. because you took it out of an Arduino board or ordered an already-bootloaded ATmega), you can skip this section.
To burn the bootloader, follow these steps:
  1. Upload the ArduinoISP sketch onto your Arduino board. (You'll need to select the board and serial port from the Tools menu that correspond to your board.)
  2. Wire up the Arduino board and microcontroller as shown in the diagram to the right.
  3. Select "Arduino Duemilanove or Nano w/ ATmega328" from the Tools > Board menu. (Or "ATmega328 on a breadboard (8 MHz internal clock)" if using the minimal configuration described below.)
  4. Run Tools > Burn Bootloader > w/ Arduino as ISP.
You should only need to burn the bootloader once. After you've done so, you can remove the jumper wires connected to pins 10, 11, 12, and 13 of the Arduino board.
After completing the above process now our task is build the board
Solder all components by following above circuit.. Use ftdi chip to program ur new ARDUINO..or other wise u can use your ARDUINO board as programmer...


😊😴😁

Tuesday, 16 June 2015

Controlling home appliances wireless......!!!

Hiiiii frnds ...today iam with new prototype . i.e remote controlling of home appliances..this can control almost all electrical appliances using some common wireless technologies like
IR remote control
DTMF based controlling..
Tools I used here for developing this project is arduino ide..
Components for this project are
Atmega328p ic's( one for IR and other for DTMF)
Tsop sensor
DTMF decoder which I used in earlier post
Relays (as many appliances)
16x2 lcd's (optional)

Below is the code for both IR and DTMF

//for DTMF
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);

void setup()
{
pinMode(9,INPUT);
pinMode(10,INPUT);
pinMode(11,INPUT);
pinMode(12,INPUT);
pinMode(A5,OUTPUT);
pinMode(A4,OUTPUT);
pinMode(A3,OUTPUT);
pinMode(A2,OUTPUT);
                                                                   // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
                                                                   // Print a message to the LCD.
  lcd.print("Initilizing.");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
delay(100);
lcd.clear();
}
void loop()
{
  int a,b,c,d;
a=digitalRead(9);
b=digitalRead(10);
c=digitalRead(11);
d=digitalRead(12);

if (a==0&&b==0&&c==0&&d==1)
{
  digitalWrite(A5,1);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 1 is ON");
}
else if(a==0&&b==0&&c==1&&d==0)
{
  digitalWrite(A5,0);
   lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 1 is OFF");
}
else if(a==0&&b==1&&c==0&&d==0)
{
  digitalWrite(A4,1);
    lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 2 is ON");
}
else if(a==0&&b==1&&c==0&&d==1)
{
  digitalWrite(A4,0);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 2 is OFF");
}
  else if(a==0&&b==1&&c==1&&d==1)
{
  digitalWrite(A3,1);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 3 is ON");
}
  else if(a==1&&b==0&&c==0&&d==0)
{
  digitalWrite(A3,0);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 3 is OFF");
}
delay(200);
}



Similarly for IR
#include <LiquidCrystal.h>


#include <IRremote.h>

int RECV_PIN = 8;

IRrecv irrecv(RECV_PIN);

decode_results results;
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);

void setup()
{
Serial.begin(9600);
 pinMode(8,INPUT);
pinMode(A5,OUTPUT);
pinMode(A4,OUTPUT);
pinMode(A3,OUTPUT);
pinMode(A2,OUTPUT);
 irrecv.enableIRIn(); // Start the receiver
 // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Initilizing.");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.print(".");
  delay(1000);
  lcd.clear();
  
}
void loop()
{
 
 if (irrecv.decode(&results))
 {  
  if(results.value==0x249815D2)
   {
   digitalWrite(A5,1);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 1 is ON");
}
else if((results.value==0x9D2AE0F2))
{
  digitalWrite(A5,0);
   lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 1 is OFF");
}
else if((results.value==0x5D674052))
{
  digitalWrite(A4,1);
    lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 2 is ON");
}
else if((results.value==0x3B9E84E))
{
  digitalWrite(A4,0);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 2 is OFF");
}
  else if((results.value==0xBED4BC32))
{
  digitalWrite(A3,1);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 3 is ON");
}
  else if((results.value==0x232917F2))
{
  digitalWrite(A3,0);
      lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("light 3 is OFF");
}
 irrecv.resume();
 }
delay(200);
}
 

NOTE: different remotes will get different hex values so keep in mind to change those values.



Some pics of project....

Friday, 5 June 2015

line follower robot


line follower robots work on basic concept of reflection of light, we use light sensors usually available in the market as a pair of photo diode and an LED. The concept is the LED keeps emitting light and if any obstacle
comes in its way , then the obstacle will reflect the light and that reflected light falls on the photodiode.
Now as we all know the property of photo diode is that it conducts when light falls on it...now the photo diode is connected to a "D" pin , usually known as data pin/signal pin...so now according to process we get a HIGH or logic of 5V when obstacle is there and "0V" when nothing.






Now in the above diagram we can see that 3 pins are popping out of the sensor, namely + -D
..the "+" pin needs to be connected to 5V of arduino or any microcontroller you will be using.
Now connect the black color wire to GND pin of your arduino or known as ground...or simply one can declare a pin as LOW and connect the black wire to it also.
Now comes the yellow wire...this is the wire that gives you data or signal whether object is there or not, we need to connect this wire to a digital pin mostly depends on the type of sensor here if you are not using PWM then you can connect to any pin on arduino from D13-D2.

Now in same fashion connect left and right sensors...after wiring check everything and now upload this program assuming that 2 motors with a L293D motor driver are all ready hooked.

Now the basic working is when the sensors are on white part the value on data pin is HIGH and when they are on black line the value on data pin is LOW, as black color doesnt reflect light so photodiode stays inactive and hence giving a LOW, so using these conditions we can make some test cases and make the robot act accordingly by turning and changing the wheel direction.





//*line follower code for arduino*//
int s1,s2;
void setup()
{
  pinMode(10,OUTPUT);
  pinMode(11,OUTPUT);
  pinMode(12,OUTPUT);        // these 4 pins 10,11,12,13 are for 2 motors
  pinMode(13,OUTPUT);
  pinMode(2,INPUT);             // these 2 pins 2 and 3 are for sensors
  pinMode(3,INPUT);
}
void loop()
{
  s1=digitalRead(2);
  s2=digitalRead(3);                                    //reading sensor values and storing them in variables l & r
  if(s1==HIGH && s2==HIGH)
  {
    digitalWrite(10,HIGH);
    digitalWrite(11,LOW);
    digitalWrite(12,HIGH);
    digitalWrite(13,LOW);
  }
  else if(s1==HIGH && s2==LOW)                   //checking the conditions
  {
    digitalWrite(10,HIGH);
    digitalWrite(11,LOW);
    digitalWrite(12,LOW);
    digitalWrite(13,HIGH);
  }
  else if(s1==LOW && s2==HIGH)
  {
    digitalWrite(10,LOW);
    digitalWrite(11,HIGH);
    digitalWrite(12,HIGH);
    digitalWrite(13,LOW);
   }
 delay(100);
}
//*ends here*//


In similar way you can do your line follower by using WINAVR software also below ode just connect the hardware according to the bellow code and compile it finally a HEX file is generated just dump that hex file to microcontroller with avaliable tools like HIDBOOT flash etc...

Microcontroller:....ATmega-8
Clock:..............12mhz
compiler :WinAVR-20100110
Connection details

Left sensor-------------------------PORTC 0
Right sensor------------------------PORTC 1

Left motor +ve----------------------PORTD 7 M7
Left motor -ve----------------------PORTD 6 M6
Right motor -ve---------------------PORTD 5 M5
Right motor +ve---------------------PORTD 4 M4
***********************************************************************/

#include<avr/io.h>

int main(void)
{
  DDRC=0X00; // Initialization of PORTC as input for sensor
  PORTC=0X00;
  
  DDRD=0XF0; // Initailization of PORTD as output for MOTOR
  PORTD=0X00;
  
  while(1)
  {
if((PINC & 0X01)==0X01) //if Left Sensor comes upon the black line
{
PORTD=0X10;               // Turn LEFT
}
else if((PINC & 0X02)==0X02) // if Right Sensorcomes upon the black line
{
PORTD=0x40; // Turn RIGHT
}
else
{
PORTD=0X50; // Move Forward
}
  }