Friday 22 May 2015

Arduino lesson 16 : Controlling other devices with Arduino.

Intro to topic :

Once you are able to get the LED controlled from the TV remote it is only one step further process to control something more bigger then just LED so controlling of relays from arduino and controlling other devices from relays can be usefull in autmoation projects so here is the tuturial.

 please refer to the last tuturial i have written to control led from TV remote to complete this one.

Hardware required :

  1. Arduino UNO board.
  2. TV remote
  3. IR receiver
  4. Relay (with coil rating with 6VDC Or 5VDC)
  5. Connecting wires/Jumper wires.
  6. PC to configure arduino board (with arduino software installed).
  7. Bread board.





Explanation to Circuit :

As we have to control external circuit or element through relay first of all we have to consider the relay structure its working principle and how to operate it for automation of things.




Here i have posted two pictures of most commonly used DC relays after applying 5VDC to its coil terminals the relay coil will get energized and the movable pin will get connected with NO point and after releasing the voltage the movable pin will gets to its start position with NC pin so this is the key principle to remember while working with relays of any kind.

The circuit we have shown is used to operate the relay with Arduino board directly by applying 5Vdc and Gound to jack1 and middle pin will goto the transistor base pin which will amplify the arduino Current of 50ma max to 200ma round about and which will be enough to energize the relay coil. The led1 will only indicate the ON and OFF the state of relay and can be omitted.


Steps to follow :


  1. Connect the Circuit according to schematic image on bread board.
  2. Plud the Middle pin of jack1 to arduino pin 5.
  3. Connect the 5v and groung connections correctly.
  4. Use Qn3904 or D400 transister (Recommended and tested).
  5. Check polaroty of Transister before applying to any Circuit.
  6. The resisters and LED part of circuit is not much essential so you can ignore it the circuit will still work better.
  7. Connect JP2 pin 2 relay on arduino PIN 13 of LED and power it up with 5v and ground.
  8. open up the Arduino IDE in PC and upload the following code.
  9. After succesfull u[loading you can control the devices with your tv remote.
  10. Whatever switch which you want to get controlled you can connect it to relay outputs. or at JP3 connector.


Code to be uploaded :


#include <IRremote.h>
#define irPin 3
IRrecv irrecv(irPin);
decode_results results;
int vcc = 12;
int gnd = 11;
int in = 10 ;
int led = 13;
int light = 4; 
void setup() {
   Serial.begin(9600);
   pinMode(vcc,OUTPUT);
   pinMode(led,OUTPUT);
   pinMode(gnd,OUTPUT);
   pinMode(in,INPUT);
   digitalWrite(vcc, HIGH);
  digitalWrite(gnd, LOW);
  digitalWrite(led, LOW);
  digitalWrite(light, LOW);// 
  
   
   irrecv.enableIRIn();
}
 
void loop() {
   if (irrecv.decode(&results)) {
 
      switch (results.value) {
         case 0xFF30CF:
            Serial.println("1");
            break;
 
         case 0xFF18E7:
            Serial.println("2");
            break;
 
         case 0xFF7A85:
            //Serial.println("POWER");
             if(digitalRead(13)==HIGH)
            {
              digitalWrite(led, LOW);// turn on the led on pin 13
              digitalWrite(light, LOW);// 
              Serial.println("LED Turned OFF");
            }
            else if(digitalRead(13)==LOW)
            {
              digitalWrite(led, HIGH);// turns off the led at pin 13
              digitalWrite(light, HIGH);// 
              Serial.println("LED Turned ON");
            }
            break;

       }
         
         
 
   irrecv.resume();
   }
}















If you have any more things to ask let it be in comments i will try to more explain it.

Arduino Lesson 15 : Blinking LED on Arduino UNO with IR(TV remote)

Intro to topic :

When we talk about communicating with arduino boards there are many many possibilities either by using buttons,keypads. sensors.shields or wireless mediums. The simplest wireless medium is to use IR sensors with arduino. So here is the tutorial how to use them with arduino and use them to control other things wirelessly.

Hardware required :

  1. Arduino UNO board.
  2. IR sensor TSOP 1738
  3. Any IR transmitter or TV remote.
  4. Connecting wires/Jumper wires.
  5. PC to configure arduino board (with arduino software installed).
  6. Bread board.




Explanation to Circuit :

As i have shown you the fritzing image the IR sensor TSOP1738 has three pins out of which two pins are used to power it up from 5v and ground and the third pin whenever recieves any IR signal on it produces on TTL signal or produces on hex value related to signal incident on it. So this trick can be used to detect the hex codes related to any button of IR sender or  IR based remote like TV remote.


Whenever TV remote button is pressed the infrared signal falls upon the reciever and then decoded by it to arduino to tell it which key is being pressed. so now we can decide what action we want to take after any specific key is being pressed by using its HEX code and making a case related in our code.

Steps to follow :


  1. Connect the Circuit according to schematic image on bread board.
  2. Power up the IC by applying it the 5v and ground.
  3. Connect the 5v and groung connections correctly and make sure they are connected to right numbered pins.
  4. Once connected correctly connect arduino to PC.
  5. open up the Arduino IDE in PC and upload the following code.



Code to be uploaded :

#include <IRremote.h>
#define irPin 2
IRrecv irrecv(irPin);
decode_results results;

void setup()
{
   Serial.begin(9600);
   irrecv.enableIRIn();
}

void loop()
{
   if (irrecv.decode(&results))
      {
      Serial.print("0x");
      Serial.println(results.value, HEX);
      delay(250);
      irrecv.resume();
      }
}




Once you uploaded the Code open up your serial monitor in Arduino IDE and take any IR remote in your home and come in front of your circuit and press any button in front of it and see the  magic. As you press any key your key code will be decoded and HEX equivalent will be shown up in serial monitor. So this shows that you have used this IC correctly and these codes can be further used in different projects like automation of devices with TV remotes.

Notice down all HEX codes of your remote with every button on page to use them here.




Steps to follow :

  1. Now once you got HEX codes of your TV remote upload the following code by changing the HEX code values as according to your own Remote.





#include <IRremote.h>
#define irPin 10
IRrecv irrecv(irPin);
decode_results results;
int vcc = 12;
int gnd = 11;
int in = 10 ;
int led = 13;
int light = 4; 
void setup() {
   Serial.begin(9600);
   pinMode(vcc,OUTPUT);
   pinMode(led,OUTPUT);
   pinMode(gnd,OUTPUT);
   pinMode(in,INPUT);
   digitalWrite(vcc, HIGH);
  digitalWrite(gnd, LOW);
  digitalWrite(led, LOW);
  digitalWrite(light, LOW);// 
  
   
   irrecv.enableIRIn();
}
void loop() {
   if (irrecv.decode(&results)) {
      switch (results.value) {
         case 0xFF30CF:
            Serial.println("1");
            break;
         case 0xFF18E7:
            Serial.println("2");
            break;
         case 0xFF7A85:
            //Serial.println("POWER");
             if(digitalRead(13)==HIGH)
            {
              digitalWrite(led, LOW);// turn on the led on pin 13
              digitalWrite(light, LOW);// 
              Serial.println("LED Turned OFF");
            }
            else if(digitalRead(13)==LOW)
            {
              digitalWrite(led, HIGH);// turns off the led at pin 13
              digitalWrite(light, HIGH);// 
              Serial.println("LED Turned ON");
            }
            break;

       }
         
         
   irrecv.resume();
   }
}













  1. now once you uploaded this code change the HEX code for your tv remote so this code will work for you.
  2. every time you press the key which is associated with to turn on or off the LED on arduino board the LED will once turn on and then turns off.
  3. You can also check the status on serial monitor for more details because the Message will be displayed accordingly there that LED is turned on or Off.

If you have any more things to ask let it be in comments i will try to more explain it.

Sunday 17 May 2015

Arduino Lesson 14 : Interfacing IR sensor with Arduino UNO

Intro to topic :

When we talk about communicating with arduino boards there are many many possibilities either by using buttons,keypads. sensors.shields or wireless mediums. The simplest wireless medium is to use IR sensors with arduino. So here is the tutorial how to use them with arduino.

Hardware required :

  1. Arduino UNO board.
  2. IR sensor TSOP 1738
  3. Connecting wires/Jumper wires.
  4. PC to configure arduino board (with arduino software installed).
  5. Bread board.



Explanation to Circuit :

As i have shown you the fritzing image the IR sensor TSOP1738 has three pins out of which two pins are used to power it up from 5v and ground and the third pin whenever recieves any IR signal on it produces on TTL signal or produces on hex value related to signal incident on it. So this trick can be used to detect the hex codes related to any button of IR sender or  IR based remote like TV remote.




Steps to follow :


  1. Connect the Circuit according to schematic image on bread board.
  2. Power up the IC by applying it the 5v and ground.
  3. Connect the 5v and groung connections correctly and make sure they are connected to right numbered pins.
  4. Once connected correctly connect arduino to PC.
  5. open up the Arduino IDE in PC and upload the following code.



Code to be uploaded :

#include <IRremote.h>
#define irPin 2
IRrecv irrecv(irPin);
decode_results results;

void setup()
{
   Serial.begin(9600);
   irrecv.enableIRIn();
}

void loop()
{
   if (irrecv.decode(&results))
      {
      Serial.print("0x");
      Serial.println(results.value, HEX);
      delay(250);
      irrecv.resume();
      }
}




Once you uploaded the Code open up your serial monitor in Arduino IDE and take any IR remote in your home and come in front of your circuit and press any button in front of it and see the  magic. As you press any key your key code will be decoded and HEX equivalent will be shown up in serial monitor. So this shows that you have used this IC correctly and these codes can be further used in different projects like automation of devices with TV remotes.




If you have any more things to ask let it be in comments i will try to more explain it.

Saturday 16 May 2015

Arduino Lesson 13 : Controlling External Relays

Intro to topic :

Now its time to talk about little bit of external hardware we can control or attach with arduino boards to control other hardware or boards. One of the most used automatically operation switches is relays which is used in electronics and many smart applications to control so here is tutorial you can follow and know how to control relays through Arduino

Hardware required :

  1. Arduino UNO board.
  2. Relay (with coil rating with 6VDC Or 5VDC)
  3. Connecting wires/Jumper wires.
  4. PC to configure arduino board (with arduino software installed).
  5. Bread board.



Explanation to Circuit :

As we have to control external circuit or element through relay first of all we have to consider the relay structure its working principle and how to operate it for automation of things.




Here i have posted two pictures of most commonly used DC relays after applying 5VDC to its coil terminals the relay coil will get energized and the movable pin will get connected with NO point and after releasing the voltage the movable pin will gets to its start position with NC pin so this is the key principle to remember while working with relays of any kind.

The circuit we have shown is used to operate the relay with Arduino board directly by applying 5Vdc and Gound to jack1 and middle pin will goto the transistor base pin which will amplify the arduino Current of 50ma max to 200ma round about and which will be enough to energize the relay coil. The led1 will only indicate the ON and OFF the state of relay and can be omitted.


Steps to follow :


  1. Connect the Circuit according to schematic image on bread board.
  2. Plud the Middle pin of jack1 to arduino pin 5.
  3. Connect the 5v and groung connections correctly.
  4. Use Qn3904 or D400 transister (Recommended and tested).
  5. Check polaroty of Transister before applying to any Circuit.
  6. The resisters and LED part of circuit is not much essential so you can ignore it the circuit will still work better.
  7. open up the Arduino IDE in PC and upload the following code.



Code to be uploaded :

int relay =5;

void setup() {
  pinMode(relay, OUTPUT);     
}

void loop() {
                                             digitalWrite(led, HIGH);   // turn the relay on (HIGH is the voltage level)
  delay(2000);               // wait for a  2 second
  digitalWrite(led, LOW);    // turn the relay off by making the voltage LOW
  delay(2000);               // wait for a 2 second
}


Once you uploaded the Code you will clearly can listen the voice of TIK TIK from relay after every two seconds and more you can test the continuity of relay ports with DMM(digital multimeter) or apply any load to get on and off for every two seconds.


If you have any more things to ask let it be in comments i will try to more explain it.

Friday 15 May 2015

Arduino Lesson 12 : Arduino UNO with 4*4 Keypad and 16*2 LCD

Intro to topic :

Keyboard or in this case keypad is very essential for many types of user data entry like passwords,number, or data integers so it is important to know about interfacing of keypad with arduino and manipulating it. Here i am discussing that how to interface keypad with arduino UNO.
Some time we needed that data we are entering should be shown to some sort of display or screen we used LCD to display the data entered.

Hardware required :

  1. Arduino UNO board.
  2. Hex keypad 4*4
  3. Connecting wires/Jumper wires.
  4. PC to configure arduino board (with arduino software installed).
  5. Bread board.


Steps to follow :


  1. Connect the Keypad and LCD according to image.
  2. Use equal length jumper wires for ease.
  3. After this connect the board to PC by USB cable and then open up the IDE in PC
  4. Then upload the following Code.



Code to be uploaded :


#include<LiquidCrystal.h>  
LiquidCrystal lcd(7,6,5,4,3,2); 
int row[]={A1,A0,8,9};// Defining row pins of keypad connected to Arduino pins
int col[]={10,11,12,13};//Defining column pins of keypad connected to Arduino
int i,j,lcd_count,count=1,key_id=0,flag,entry=0;// See About the Program 
int col_scan;// Variable to identify a key press
char temp_press; // Variable to hold value of key press
char check[6],pass[6]; // See About the Program

void setup()
{
lcd.begin(16,2);
for(i=0;i<=3;i++)
{
pinMode(row[i],OUTPUT);
pinMode(col[i],INPUT);
digitalWrite(col[i],HIGH);
}
lcd.print("SET 5 Digit PASS");
}

/* Main Program Begins */

void loop()
{ 
 while(entry<=4)// Password Setting Loop begins
{
SetPassword();
}
// Password Setting Loop Ends

key_id=0;
keyscan(); // Scan for a Key Press

/* Actions on Key Press begins */

if(key_id==1) // Condition to Check Key is Pressed
{
 check[count]=temp_press;
count++;

/* Condition to Unlock Begins*/

if(temp_press=='A')
{
  checkPassword();
if(flag==0)
{
lcd.setCursor(0,0);
lcd.print("UNLOCKED");

}else{ 
lcd.setCursor(0,0);
lcd.print("WRONG PASSWORD");
delay(200);
lcd.clear();
lcd.print("LOCKED");
}
count=1; // Resetting the counter variable
}

/* Condition to Unlock Ends*/

/* Condition to Change Password Begins */

else if(temp_press=='C')
{
checkPassword();
if(flag==0)
{
lcd.setCursor(0,0);
lcd.print("ENTER NEW PASS");
key_id=0;
entry=0;
}else{ 
lcd.setCursor(0,0);
lcd.print("WRONG PASSWORD");
}
count=1; // Resetting the counter variable
}

/* Condition to Change Password Ends */

/* Condition to LOCK Begins*/

else if(temp_press=='B')
{
lcd.setCursor(0,0);
lcd.print("LOCKED");
count=1; // Resetting the counter variable
}
/* Condition to LOCK Ends*/
}

/* Actions on Key Press Ends*/
}

/* Main Program Ends */


void SetPassword() // Subroutine to SET User Defined Password
{
keyscan();
if(key_id==1)
{
if(temp_press=='A'||temp_press=='C'||temp_press=='B') // Condition to Check for an Invalid Keypress 
{
lcd.setCursor(0,0);
lcd.print("INVALID KEYS");
entry=0;
}
else 

{
  pass[entry]=temp_press;

}
}
key_id=0;
if(entry==5)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("PASSWORD SET & LOCKED");
}} // Subroutine to SET Password ENDS

char keyscan()// Subroutine to Scan Keypad for a Keypress
{
for(i=0; i<=3; i++)
{
digitalWrite(row[0],HIGH);
digitalWrite(row[1],HIGH);
digitalWrite(row[2],HIGH);
digitalWrite(row[3],HIGH);
digitalWrite(row[i],LOW);
for(j=0; j<=3; j++)
{
col_scan=digitalRead(col[j]);
if(col_scan==LOW)
{
  key_id=1;
  entry++;
temp_press=keypress(i,j);
lcd.setCursor(lcd_count++,1);
lcd.print(temp_press);
if(temp_press=='A'||temp_press=='C'||temp_press=='B')
{
lcd_count=0;
lcd.clear();
}
delay(300);
break;
}}
}}// Subroutine to Scan Keypress Ends

char keypress(int i, int j) // Subroutine to Identify the value of Key pressed
{
if(i==0&&j==0)
{
return('1');
}
if(i==0&&j==1)
{
return('2');
}
if(i==0&&j==2)
{
return('3');
}
if(i==0&&j==3)
{
return('A');
}
if(i==1&&j==0)
{
return('4');
}
if(i==1&&j==1)
{
return('5');
}
if(i==1&&j==2)
{
return('6');
}
if(i==1&&j==3)
{
return('B');
}
if(i==2&&j==0)
{
return('7');
}
if(i==2&&j==1)
{
return('8');
}
if(i==2&&j==2)
{
return('9');
}
if(i==2&&j==3)
{
return('C');
}
if(i==3&&j==0)
{
return('*');
}
if(i==3&&j==1)
{
return('0');
}
if(i==3&&j==2)
{
return('#');
}
if(i==3&&j==3)
{
return('D');
}
} // Subroutine to identify Keypress Ends

void checkPassword() // Subroutine to Check User Input Data with SET Password
{
flag=0;
for(i=1;i<=5&&flag==0;i++)
{
if(check[i]==pass[i])
{
flag=0;
}
else 
{flag=1;
}}} // Subroutine to check password ends

                                

Once the code is uploaded you can follow up the screen and any time you input correct code the pin will be unlocked


Arduino Lesson 11 : Interfacing 4*4 Hex Keypad with Arduino UNO

Intro to topic :

Keyboard or in this case keypad is very essential for many types of user data entry like passwords,number, or data integers so it is important to know about interfacing of keypad with arduino and manipulating it. Here i am discussing that how to interface keypad with arduino UNO.

Hardware required :

  1. Arduino UNO board.
  2. Hex keypad 4*4
  3. Connecting wires/Jumper wires.
  4. PC to configure arduino board (with arduino software installed).
  5. Bread board.


Steps to follow :


  1. Connect the Keypad according to image.
  2. Use equal length jumper wires for ease.
  3. After this connect the board to PC by USB cable and then open up the IDE in PC
  4. Then upload the following Code.



Code #1 to be uploaded :

int row[]={6,7,8,9};// Defining row pins of keypad connected to Aeduino pins
int col[]={10,11,12,13};//Defining column pins of keypad connected to Arduino
int i,j; // Two counter variables to count inside for loop
int col_scan; // Variable to hold value of scanned columns
void setup()
{
Serial.begin(9600);
for(i=0;i<=3;i++)
{
pinMode(row[i],OUTPUT);
pinMode(col[i],INPUT);
digitalWrite(col[i],HIGH);
} }
void loop()
{ 
for(i=0; i<=3; i++)
{
digitalWrite(row[0],HIGH);
digitalWrite(row[1],HIGH);
digitalWrite(row[2],HIGH);
digitalWrite(row[3],HIGH);
digitalWrite(row[i],LOW);
for(j=0; j<=3; j++)
{
col_scan=digitalRead(col[j]);
if(col_scan==LOW)
{
keypress(i,j);
delay(300);
}}
}}
void keypress(int i, int j)
{
if(i==0&&j==0)
Serial.println("1");
if(i==0&&j==1)
Serial.println("2");
if(i==0&&j==2)
Serial.println("3");
if(i==0&&j==3)
Serial.println("A");
if(i==1&&j==0)
Serial.println("4");
if(i==1&&j==1)
Serial.println("5");
if(i==1&&j==2)
Serial.println("6");
if(i==1&&j==3)
Serial.println("B");
if(i==2&&j==0)
Serial.println("7");
if(i==2&&j==1)
Serial.println("8");
if(i==2&&j==2)
Serial.println("9");
if(i==2&&j==3)
Serial.println("C");
if(i==3&&j==0)
Serial.println("*");
if(i==3&&j==1)
Serial.println("0");
if(i==3&&j==2)
Serial.println("#");
if(i==3&&j==3)
Serial.println("D");
}

                                                 OR

Code #2 to be uploaded :

int r1=6;
int r2=7;
int r3=8;
int r4=9;
int c1=10;
int c2=11;
int c3=12;
int c4=13;
int colm1;
int colm2;
int colm3;
int colm4;

void setup()
{
  pinMode(r1,OUTPUT);
  pinMode(r2,OUTPUT);
  pinMode(r3,OUTPUT);
  pinMode(r4,OUTPUT);
  pinMode(c1,INPUT);
  pinMode(c2,INPUT);
  pinMode(c3,INPUT);
  pinMode(c4,INPUT);
  Serial.begin(9600);
  digitalWrite(c1,HIGH);
  digitalWrite(c2,HIGH);
  digitalWrite(c3,HIGH);
  digitalWrite(c4,HIGH);
}
void loop()
{
  digitalWrite(r1,LOW);
  digitalWrite(r2,HIGH);
  digitalWrite(r3,HIGH);
  digitalWrite(r4,HIGH);
  colm1=digitalRead(c1);
  colm2=digitalRead(c2);
  colm3=digitalRead(c3);
  colm4=digitalRead(c4);
  if(colm1==LOW)
  {Serial.println("1");
   delay(200);}
  else
  {
   if(colm2==LOW)
   {Serial.println("2");
    delay(200);}
   else
   {
   if(colm3==LOW)
   {Serial.println("3");
     delay(200);}
   else
   {
   if(colm4==LOW)
   {Serial.println("A");
      delay(200);}
   }}}

  digitalWrite(r1,HIGH);
  digitalWrite(r2,LOW);
  digitalWrite(r3,HIGH);
  digitalWrite(r4,HIGH);
  colm1=digitalRead(c1);
  colm2=digitalRead(c2);
  colm3=digitalRead(c3);
  colm4=digitalRead(c4);
  if(colm1==LOW)
  {Serial.println("4");
    delay(200);}
  else
  {
   if(colm2==LOW)
   {Serial.println("5");
    delay(200);}
   else
   {
   if(colm3==LOW)
   {Serial.println("6");
      delay(200);}
   else
   {
   if(colm4==LOW)
   {Serial.println("B");
       delay(200);}
   }}}

  digitalWrite(r1,HIGH);
  digitalWrite(r2,HIGH);
  digitalWrite(r3,LOW);
  digitalWrite(r4,HIGH);
  colm1=digitalRead(c1);
  colm2=digitalRead(c2);
  colm3=digitalRead(c3);
  colm4=digitalRead(c4);
  if(colm1==LOW)
  {Serial.println("7");
     delay(200);}
  else
  {
   if(colm2==LOW)
   {Serial.println("8");
       delay(200);}
   else
   {
   if(colm3==LOW)
   {Serial.println("9");
        delay(200);}
   else
   {
   if(colm4==LOW)
   {Serial.println("C");
        delay(200);}
   }}}
  digitalWrite(r1,HIGH);
  digitalWrite(r2,HIGH);
  digitalWrite(r3,HIGH);
  digitalWrite(r4,LOW);
  colm1=digitalRead(c1);
  colm2=digitalRead(c2);
  colm3=digitalRead(c3);
  colm4=digitalRead(c4);
  if(colm1==LOW)
  {Serial.println("*");
      delay(200);}
  else
  {
   if(colm2==LOW)
   {Serial.println("0");
        delay(200);}
   else
   {
   if(colm3==LOW)
   {Serial.println("#");
      delay(200);}
   else
   {
   if(colm4==LOW)
   {Serial.println("D");
       delay(200);}

   }}}

}

After the successful uploading of program goto PC and open up serial monitor and the press any key what ever you will press automatically comes on screen of PC in serial monitor.


Notice that this code can be used to display up characters on the screen of LCD we have covered in last Lesson.

Thursday 14 May 2015

Arduino lesson 10 : Interfacing 16*2 LCD with Arduino UNO

Intro to topic :

Now once you have got some confidence of using some very basic operation from your arduino board in last tutorials. Now its time to take our efforts to next level of interfacing external hardware i.e LCD display (16*2) 

Hardware required :

  1. Arduino UNO board.
  2. LCD (of any color)
  3. POT 500ohm - 1Kohm (for controlling LCD brightness)
  4. Resister 560ohm (not mandatory)
  5. Connecting wires/Jumper wires.
  6. PC to configure arduino board (with arduino software installed).
  7. Bread board.


Steps to follow :


  1. Connect the Lcd according to Fritzing image
  2. The resister if added good otherwise it is not necessary to put on resister because the current is limited to each pin of arduino boards.
  3. After this connect the board to PC by USB cable and then open up the IDE in PC.
  4. Goto File>Examples>LiquidCrystal>HelloWorld
  5. The following Code will open.



Code to be uploaded :

/*
  LiquidCrystal Library - Hello World

 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.

 This sketch prints "Hello World!" to the LCD
 and shows the time.

  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * LCD VSS pin to ground
 * LCD VCC pin to 5V
 * 1K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)


 */

// include the library code:
#include <LiquidCrystal.h>

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

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis() / 1000);
}




Once you have uploaded the code correctly just see that Lcd will turn on and the word "hello world" will be shown on screen if not then change the value of POT resistor to change lcd contrast and brightness.

Arduino lesson 9 : How to fade LED brightness continously :

Intro to topic :

Some times we need that some variable or some analog voltage continuously varies from one value to another one like starting LED from zero brightness to its max and then reverting all the process can be tricky and will be useful for us to handle situations like this.

Hardware required :

  1. Arduino UNO board.
  2. LED (of any color)
  3. Resister 330ohm (not mandatory)
  4. Connecting wires/Jumper wires.
  5. PC to configure arduino board (with arduino software installed).
  6. Bread board.


Fritzing project
Schemetic diagram

Steps to follow :


  1. Connect the Led by identifying the positive lead of led according to Fritzing image
  2. The resister if added good otherwise it is not necessary to put on resister because the current is limited to each pin of arduino boards.
  3. After this connect the board to PC by USB cable and then open up the IDE in PC.
  4. Goto File>Examples>01.Basics>fade
  5. The following Code will open.



Code to be uploaded :

/*
 Fade

 This example shows how to fade an LED on pin 13
 using the analogWrite() function.

 This example code is in the public domain.
 */

int led = 13;           // the pin that the LED is attached to
int brightness = 0;    // how bright the LED is
int fadeAmount = 5;    // how many points to fade the LED by

// the setup routine runs once when you press reset:
void setup() {
  // declare pin 13 to be an output:
  pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // set the brightness of pin 13:
  analogWrite(led, brightness);

  // change the brightness for next time through the loop:
  brightness = brightness + fadeAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}




Once you have uploaded the code correctly just see that Led will start fading and increasing its brightness to zero and max positions.

Samsun New launch with Arduino




When you think about Samsung, the first products that come to mind are probably phones or televisions, not Maker-focused electronics. Today, with their announcement at Internet of Things World, Samsung has entered the Maker world with their ARTIK platform, an Arduino compatible family of devices targeted towards Internet of Things applications.
Combining this powerful hardware with the ease of use and existing knowledge base of the Arduino platform, Samsung hopes to make development of IoT platforms easy to get off the ground:Currently there are three ARTIK devices: The ARTIK 1, ARTIK 5, and ARTIK 10. All are multi-core ARM processors with built in Bluetooth Low Energy. The ARTIK 5 and 10 also include Wi-Fi, BT, Zigbee, and Thread wireless connections.
“Our approach is to provide open platforms to help accelerate the development of IoT for our customers, developers, and end users” said Curtis Sasaki, Vice President of Ecosystem, Samsung Electronics. “Being part of Arduino’s Certified Program helps millions of developers familiar with Arduino IDE to take advantage and focus all of their energy to building new and innovative products.”

Arduino lesson 8 : Reading analog voltages :

Intro to topic :

It is sometimes essential to us read the analog value from different sensors and Shields in order to perform certain tasks let see resistance change in some path or voltage drops of some sort. So in arduino you can read analog quantities directly without any external hardware.

Hardware needed :

  1. Arduino UNO board
  2. Bread board
  3. Jumper wires
  4. PC on which the arduino IDE is installed
  5. Variable resisters (Potentiometers)


Steps to follow :

  1. First of All complete the circuit as below


  1. Connect the one pin of POT to Arduino Pin A0 and other pins to 5V and GND respectively.
  2. Connect the arduino board to PC and open up the software.
  3. Goto file>examples>01.basic>Analog read serial.
  4. After opening it upload this code to your board and then wait for uploading.
  5. Now open Up serial monitor from tools>serial monitor Or simply press Ctrl+Shift+M.

  1. You will see that there will be list of values going on in Serial monitor screen once you get this.
  2. Change the POT value by moving its knob to some other point as you change the value on serial monitor will automatically change.

Code to Upload :

*
  AnalogReadSerial
  Reads an analog input on pin 0, prints the result to the serial monitor.
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

 This example code is in the public domain.
 */

// the setup routine runs once when you press reset:
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);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(1);        // delay in between reads for stability
}





Wednesday 13 May 2015

Arduino Lesson 7 : LED blinking on Arduino UNO R3

Project :

We are going to do this project in which we can blink led either on board or off the board according to our wish.

Hardware required :

  1. Arduino UNO board.
  2. LED (of any color)
  3. Resister 330ohm (not mandatory)
  4. Connecting wires/Jumper wires.
  5. PC to configure arduino board (with arduino software installed).
  6. Bread board.


Fritzing project
Schemetic diagram

Steps to follow :


  1. Connect the Led by identifying the positive lead of led according to Fritzing image
  2. The resister if added good otherwise it is not necessary to put on resister because the current is limited to each pin of arduino boards.
  3. After this connect the board to PC by USB cable and then open up the IDE in PC.
  4. Goto File>Examples>01.Basics>blink
  5. The following Code will open.
  6.  
    Blink Code

    or
    Simply pastes this code in your file and upload this one.







    /*
      Blink
      Turns on an LED on for one second, then off for one second, repeatedly.
     
      This example code is in the public domain.
     */

     
    // Pin 13 has an LED connected on most Arduino boards.
    // give it a name:
    int led = 13;

    // the setup routine runs once when you press reset:
    void setup() {                
      // initialize the digital pin as an output.
      pinMode(led, OUTPUT);     
    }

    // the loop routine runs over and over again forever:
    void loop() {
      digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
      delay(1000);               // wait for a second
      digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
      delay(1000);               // wait for a second
    }





  7. By clicking the new window will open in which the piece of code will be written.
  8. Check that your board is correctly selected and serial port is correct.
  9. Click on upload button and wait for code to get uploaded.
  10. After successful uploading of code the LED will start blinking automatically.
  11. Notice that every time you restart your Arduino Board the Led will automatically start blinking it self.

Arduino lesson 6 : Getting started With Arduino UNO R3

Arduino UNO R3 At Glance :




This board is mostly used over projects due to its wast range of products shields and different hardwares can be easily attached to it.

Arduino UNO board
   
Originally taken from Arduino.cc

This board also has one hardware serial port (Rx/Tx) for serial communication with other TTL boards or other boards from arduino.


This is a little about this board much more can be seen on here and in next lessons i will by the help of ALLAH Almighty will continue my blog towards tutorials related to different projects and hardwares.


If you have any query please feel free to ask and let your questions in comment section below.