Pages

Thursday 24 December 2015

Circuit to interface HC-05 bluetooth module to Arduino uno

Household equipment such as bulb or fan controlled using your android device is an interesting project which most hobbyists want to do. A communication should be there between the android device and household equipment through some microcontroller boards such as Arduino uno. Bluetooth is a simple method to establish a communication between android device and household equipment. Here, I am using a HC-05 bluetooth module to communicate with android device. HC-05 is connected to Arduino uno to receive the data sent from android device. Depending on the data received from android device, we can use this Arduino uno to control our household equipment.
Connections are done as shown in the following diagram. Connections can be summarized as,
  1. 5V pin of Arduino uno is connected to the VCC terminal of HC-05 bluetooth module.
  2. Gnd pin of Arduino uno is connected to the Gnd terminal of HC-05 bluetooth module.
  3. RX pin of Arduino uno is connected to the TX terminal of HC-05 bluetooth module.
  4. TX pin of Arduino uno is connected to the RX terminal of HC-05 bluetooth module.

After completing the circuit, upload the following program to your Arduino board. Disconnect RX and TX pins connected to Arduino uno for successful uploading. Otherwise, uploading will be failed. After successful uploading, reconnect the RX and TX pins.

char junk;
String inputString="";

void setup()
{
  while (!Serial);
  Serial.begin(9600);
}

void loop()
{
  if(Serial.available())
  {
    while(Serial.available())
    {
      char inChar = (char)Serial.read(); //read the input
      inputString += inChar;             //make a string of the characters coming on serial
    }
    Serial.println(inputString);
    while (Serial.available() > 0)  
    { 
      junk = Serial.read() ; 
    } 
    inputString = "";
  }
}

Now, open the serial monitor from Arduino IDE. Nothing will be displayed in the serial monitor. Still, you must keep the serial monitor open until the remaining steps also get completed.

Next steps will be in your android device. Install Bluetooth Terminal application in your android device from Google Play Store.

After installing, open Bluetooth Terminal application and connect your android device to bluetooth device HC-05.
Select your bluetooth device from a list of available devices.
If connection goes successful, your Bluetooth Terminal will be as shown below.
Now, type letters in the text box and send.
Letters sent from your android device will be displayed in the serial monitor of Arduino.

Wednesday 16 December 2015

Programming ATtiny44 / ATtiny84 using Arduino uno

We had already seen the circuit for programming ATtiny45 / ATtiny85 using Arduino uno in my previous post. ATtiny45 / ATtiny85 has fewer number of analog and digital pins. So, for bigger applications, we have to go for microcontrollers having more analog and digital pins. ATtiny44 / ATtiny84 is an example of such kind of microcontrollers. Here, we will see a method for programming ATtiny44 / ATtiny84 using Arduino uno.

Circuit is done as shown in the following diagram. An LED should be connected to the 13th pin of ATtiny44 / ATtiny84 to test the program.

Step 1 :

Disconnect the capacitor from the circuit (Capacitor connected between RESET and GND pin of Arduino uno).
Select Arduino Uno board from Tools menu.















Upload the ArduinoISP sketch to your Arduino uno.

Step 2 :

After uploading the ArduinoISP, connect the capacitor in the circuit (Capacitor connected between RESET and GND pin of Arduino uno). Then, open Blink program from your sample programs.

Change the digital pin number from 13 to 0.

Select ATtiny board from Tools menu.

When ATtiny board is selected, a Processor sub-menu will appear under Tools menu. Select your processor from Processor sub-menu. My processor is ATtiny44.

Upload the modified Blink program to your ATtiny44 / ATtiny84. If uploading is successful, LED connected to ATtiny44 / ATtiny84 will start blinking.

Monday 7 December 2015

Split video screen to play two videos together using Kdenlive in ubuntu 14.04

In certain situations, we will have to split our video screen to play two videos together side by side. Many software are there to make such videos. Here, we will see the video demonstration of splitting our video screen using kdenlive video editor in ubuntu 14.04.

Sunday 6 December 2015

Interface 16 switches to arduino uno using only 5 digital pins (HEF4067BP)

Under certain situations, we will have to interface many switches to our arduino uno. Simplest method to interface switches to arduino uno is to connect the switch directly to any one of the digital pin or analog pin of arduino uno. But, if we have to interface many switches to arduino uno, previous mentioned method is not advisable because, only 14 digital pins and 6 analog pins are available in arduino uno. If we connect switches to all these pins, we could not use this arduino uno board for any other purposes. Then, we have to go for some other methods which use minimum pins of arduino to interface maximum number of switches.

Circuit given below shows a simple method to interface 16 switches to arduino uno using only 5 digital pins. A HEF4067BP multiplexer/demultiplexer IC should be connected in between switches and arduino uno as shown in the diagram.

After completing the circuit, upload the following program to your arduino board.

int val = 0;         // variable to store the read value

int A_zero = 8;       
int A_one = 9;
int A_two = 10;
int A_three = 11;

int z = 12;

void setup()
{
  
  pinMode(z, INPUT);      // sets the digital pin "z" as input

  pinMode(A_zero, OUTPUT);      // sets the digital pin "A_zero" as output
  pinMode(A_one, OUTPUT);       // sets the digital pin "A_one" as output
  pinMode(A_two, OUTPUT);       // sets the digital pin "A_two" as output
  pinMode(A_three, OUTPUT);     // sets the digital pin "A_three" as output
  
  Serial.begin(9600);

}

void loop()
{
  // Select address 0000  
  digitalWrite(A_zero, LOW);    
  digitalWrite(A_one, LOW);     
  digitalWrite(A_two, LOW);     
  digitalWrite(A_three, LOW);   
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 1");  
    delay(50);
  }

  // Select address 0001  
  digitalWrite(A_zero, HIGH);   
  digitalWrite(A_one, LOW);     
  digitalWrite(A_two, LOW);     
  digitalWrite(A_three, LOW);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 2");  
    delay(50);
  }

  // Select address 0010  
  digitalWrite(A_zero, LOW);   
  digitalWrite(A_one, HIGH);     
  digitalWrite(A_two, LOW);     
  digitalWrite(A_three, LOW);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 3");
    delay(50);  
  }

  // Select address 0011  
  digitalWrite(A_zero, HIGH);   
  digitalWrite(A_one, HIGH);     
  digitalWrite(A_two, LOW);     
  digitalWrite(A_three, LOW);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 4");
    delay(50);  
  }

  // Select address 0100  
  digitalWrite(A_zero, LOW);   
  digitalWrite(A_one, LOW);     
  digitalWrite(A_two, HIGH);     
  digitalWrite(A_three, LOW);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 5");
    delay(50);  
  }  

  // Select address 0101  
  digitalWrite(A_zero, HIGH);   
  digitalWrite(A_one, LOW);     
  digitalWrite(A_two, HIGH);     
  digitalWrite(A_three, LOW);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 6");
    delay(50);  
  }  

  // Select address 0110  
  digitalWrite(A_zero, LOW);   
  digitalWrite(A_one, HIGH);     
  digitalWrite(A_two, HIGH);     
  digitalWrite(A_three, LOW);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 7");
    delay(50);  
  }  

  // Select address 0111  
  digitalWrite(A_zero, HIGH);   
  digitalWrite(A_one, HIGH);     
  digitalWrite(A_two, HIGH);     
  digitalWrite(A_three, LOW);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 8");
    delay(50);  
  }  

  // Select address 1000  
  digitalWrite(A_zero, LOW);   
  digitalWrite(A_one, LOW);     
  digitalWrite(A_two, LOW);     
  digitalWrite(A_three, HIGH);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 9");
    delay(50);  
  }  

  // Select address 1001  
  digitalWrite(A_zero, HIGH);   
  digitalWrite(A_one, LOW);     
  digitalWrite(A_two, LOW);     
  digitalWrite(A_three, HIGH);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 10");
    delay(50);  
  }

  // Select address 1010  
  digitalWrite(A_zero, LOW);   
  digitalWrite(A_one, HIGH);     
  digitalWrite(A_two, LOW);     
  digitalWrite(A_three, HIGH);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 11");
    delay(50);  
  }

  // Select address 1011  
  digitalWrite(A_zero, HIGH);   
  digitalWrite(A_one, HIGH);     
  digitalWrite(A_two, LOW);     
  digitalWrite(A_three, HIGH);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 12");
    delay(50);  
  }

  // Select address 1100  
  digitalWrite(A_zero, LOW);   
  digitalWrite(A_one, LOW);     
  digitalWrite(A_two, HIGH);     
  digitalWrite(A_three, HIGH);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 13");
    delay(50);  
  }

  // Select address 1101  
  digitalWrite(A_zero, HIGH);   
  digitalWrite(A_one, LOW);     
  digitalWrite(A_two, HIGH);     
  digitalWrite(A_three, HIGH);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 14");
    delay(50);  
  }

  // Select address 1110  
  digitalWrite(A_zero, LOW);   
  digitalWrite(A_one, HIGH);     
  digitalWrite(A_two, HIGH);     
  digitalWrite(A_three, HIGH);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 15");
    delay(50);  
  }

  // Select address 1111  
  digitalWrite(A_zero, HIGH);   
  digitalWrite(A_one, HIGH);     
  digitalWrite(A_two, HIGH);     
  digitalWrite(A_three, HIGH);  
  if(digitalRead(z)==1)
  {         
    Serial.println("Switch pressed is 16");
    delay(50);  
  }
}
If uploading is successful, open your serial monitor. Serial monitor will print the number of the switch pressed as shown in the following image.
Watch the video demonstration here.