Friday, 27 July 2012

7 segment with AVR

hello frends
here i provide the circuit diagram of 7 segment which is connected with AVR atmega8


link is :
http://www.mediafire.com/?74dl9a2qa77jyo6

Tuesday, 24 July 2012

title

if you want to take a training based on embedded system than contact the following number.
training place is in rajkot.



contact number : 9662010710

Wednesday, 18 July 2012

user input based 7 segment display

hello frends
here i provide the circuit diagram as well as its description
you can down load from this link
link is :


http://www.mediafire.com/?l3s8uxwpvc02ksd

Saturday, 14 July 2012

Thursday, 12 July 2012

lcd based digital alarm clock

here i provide code as well as circuit diagram of lcd based digital alarm clock....


link is....


http://www.mediafire.com/?o95k8r4t46cxdg9

Wednesday, 11 July 2012

interfacing stepper motor with 8051

you can download the code as well as circuit diagram from this link....
http://www.mediafire.com/?kxyounuc6bxvjgh

interface 16x2 lcd with 8051

It is very important to keep a track of the working of almost all the automated and semi-automated devices, be it a washing machine, an autonomous robot or anything else. This is achieved by displaying their status on a small display module. LCD (Liquid Crystal Display) screen is such a display module and a 16x2 LCD module is very commonly used. These modules are replacing seven segments and other multi segment LEDs for these purposes. The reasons being: LCDs are economical, easily programmable, have no limitation of displaying special & even custom characters (unlike in seven segments), animationsand so on. LCD can be easily interfaced with a microcontroller to display a message or status of a device. This topic explains the basics of a 16x2 LCD and how it can be interfaced with AT89C51 to display a character.

A 16xLCD means it can display 16 characters per line and there are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers.


1.      Command/Instruction Register - stores the command instructions given to the LCD. A command is an instruction given to LCD to do a predefined task like initializing, clearing the screen, setting the cursor position, controlling display etc.
2.      Data Register - stores the data to be displayed on the LCD. The data is the ASCII value of the character to be displayed on the LCD.
Commonly used LCD Command codes:
Hex Code
Command to LCD Instruction Register
1
Clear screen display
2
Return home
4
Decrement cursor
6
Increment cursor
E
Display ON, Cursor ON
80
Force the cursor to the beginning of the 1st line
C0
Force cursor to the beginning of the 2nd line
38
Use 2 lines and 5x7 matrix

Pin configuration:
Pin
Symbol
Description
 
1
VSS
Ground
0 V
2
VCC
Main power supply
+5 V
3
VEE
Power supply to control contrast
Contrast adjustment by providing a variable resistor through VCC
4
RS
Register Select
 
RS=0 to select Command Register
RS=1 to select Data Register
5
R/W
Read/write
 
R/W=0 to write to the register
R/W=1 to read from the register
6
EN
Enable
A high to low pulse (minimum 450ns wide) is given when data is sent to data pins
7
DB0
To display letters or numbers, their ASCII codes are sent to data pins (with RS=1). Also instruction command codes are sent to these pins.
8
DB1
 
9
DB2
 
10
DB3
             8-bit data pins
11
DB4
 
12
DB5
 
13
DB6
 
14
DB7
 
15
Led+
Backlight VCC
+5 V
16
Led-
Backlight Ground
0 V

Programming the LCD:
 1.      Data pin8 (DB7) of the LCD is busy flag and is read when R/W = 1 & RS = 0. When busy flag=1, it means that LCD is not ready to accept data since it is busy with the internal operations. Therefore before passing any data to LCD, its command register should be read and busy flag should be checked.
2.      To send data on the LCD, data is first written to the data pins with R/W = 0 (to specify the write operation) and RS = 1 (to select the data register). A high to low pulse is given at EN pin when data is sent. Each write operation is performed on the positive edge of the Enable signal.
 3.      To send a command on the LCD, a particular command is first specified to the data pins with R/W = 0 (to specify the write operation) and RS = 0 (to select the command register). A high to low pulse is given at EN pin when data is sent.
Displaying single character ‘A’ on LCD
The LCD is interfaced with microcontroller (AT89C51). This microcontroller has 40 pins with four 8-bit ports (P0, P1, P2, and P3). Here P1 is used as output port which is connected to data pins of the LCD. The control pins (pin 4-6) are controlled by pins 2-4 of P0 port. Pin 3 is connected to a preset of 10k? to adjust the contrast on LCD screen. This program uses the above concepts of interfacing the LCD with controller by displaying the character ‘A’ on it.
code for lcd interface :
#include<reg51.h>
#define cmdport P3
#define dataport P2
#define q 100
sbit rs = cmdport^0;  //register select pin
sbit rw = cmdport^1;  // read write pin
sbit e = cmdport^6;  //enable pin

void delay(unsigned int msec)  // Function to provide time delay in msec.
{
int i,j ;
for(i=0;i<msec;i++)
for(j=0;j<1275;j++);
}

void lcdcmd(unsigned char item)  //Function to send command to LCD
{
dataport = item;
rs= 0;
rw=0;
e=1;
delay(1);
e=0;
}

void lcddata(unsigned char item)  //Function to send data to LCD
{
dataport = item;
rs= 1;
rw=0;
e=1;
delay(1);
e=0;
}

void main()
{
lcdcmd(0x38);  // for using 8-bit 2 row mode of LCD
delay(100);
lcdcmd(0x0E);  // turn display ON for cursor blinking
delay(100);
lcdcmd(0x01);  //clear screen
delay(100);
lcdcmd(0x06);  //display ON
delay(100);
lcdcmd(0x86);  // bring cursor to position 6 of line 1
delay(100);
lcddata('A');
}


 
 
 

Tuesday, 10 July 2012

electronic code lock with user defined password using 8051

An electronic lock or digital lock is a device which has an electronic control assembly attached to it. They are provided with an access control system. This system allows the user to unlock the device with a password. The password is entered by making use of a keypad. The user can also set his password to ensure better protection. The major components include a keypad, LCD and the controller AT89C51 which belongs to the 8051 series of microcontrollers. This article describes the making of an electronic code lock using the 8051 microcontroller. 

A 4x3 matrix keypad and a 16x2 LCD have been used here. Keypad and LCD are very commonly used input & output devices, respectively. A four digit predefined password needs to be specified the user. This password is stored in the system.

While unlocking, if the entered password from keypad matches with the stored password, then the lock opens and a message is displayed on LCD. Also an output pin is made high to be used for further purpose.
The connections in the circuit are as following: port P2 of microcontroller AT89C51 is used as data input port which is connected to data pins (7-14) of LCD. P1^0, P1^1 and P1^2 pins of microcontroller are connected to control pins RS, RW and EN of LCD. Port P0 is used to take input from keypad. P0^7 has been used as lock output pin of controller.
 
As the program starts, string ‘Enter Password’ is displayed on LCD. The keypad is scanned for pressed digits one by one. Every time, row and column of the key pressed is detected and a ‘*’ is displayed on LCD corresponding to the entered number. After the four digits are entered, the user is prompted to ‘Confirm Password’ and again the input is taken through LCD. If the passwords do not match, a message is displayed to indicate ‘Wrong Password’; otherwise the user is prompted to unlock the device.
 
To unlock, user needs to ‘Enter Password’ through keypad. Again the keypad is scanned for pressed keys and corresponding digits are identified. The passkey is displayed as ‘****’ on the LCD screen. After the four digits are entered, they are compared with the pre-set password. If all the four digits match with set password, LCD displays ‘Lock Open’ and the lock output pin goes high. If the security code is wrong, ‘Wrong Password’ is sent to be displayed on LCD. The system gets locked if more than three attempts are made with wrong password to open the electronic lock. The system needs to be reset in such a case.

Code of the program :-
#include<reg51.h>
#define port P1
#define dataport P2
#define key P0
#define sec 100
sbit rs = port^0;
sbit rw = port^1;
sbit en = port^2;

sbit col1=key^4;
sbit col2=key^5;
sbit col3=key^6;
sbit row1=key^0;
sbit row2=key^1;
sbit row3=key^2;
sbit row4=key^3;
sbit lock_output=P0^7;

int check=0;
int digit[4]={0,0,0,0};
int dig_input[4]={0,0,0,0};
int dig_input_recheck[4]={0,0,0,0};

int i,k;


void delay(unsigned int msec) // Time delay function
{
int i,j ;
for(i=0;i<msec;i++)
  for(j=0;j<1275;j++);
}

void lcd_cmd(unsigned char item) // Function to send command to LCD
{
dataport = item;
rs= 0;
rw=0;
en=1;
delay(1);
en=0;
return;
}

void lcd_data(unsigned char item) // Function to send data to LCD
{
dataport = item;
rs= 1;
rw=0;
en=1;
delay(1);
en=0;
return;
}

void lcd_data_string(unsigned char *str) // Function to send data to string
{
int i=0;
while(str[i]!='\0')
{
  lcd_data(str[i]);
  i++;
  //delay(10);
}
return;
}

void lcd(unsigned char str[10])
{
lcd_cmd(0x38);
lcd_cmd(0x0e);
lcd_data_string(str);
}


void ans()
{
if(check>3)
{
  lcd_cmd(0x01);
  lcd_cmd(0x82);
  lcd_data_string(" LOCK OPEN");
  lock_output=1;
  delay(300);
  while(1);
  }
else
{
  lcd_cmd(0x01);
  lcd_cmd(0x82);
  lcd_data_string(" WRONG PASSWORD");
  lock_output=0;
  delay(300);
}                   
}

void code_check() // Function to check password
{
if(i<=3 )
{
  switch((i+1))
  {
   case 1: {
      if(dig_input[0]==digit[0])
      {
       check=check+1;
      }
      break;
     }
   case 2: {
      if(dig_input[1]==digit[1])
      {
       check=check+1;
      }
      break;
     }
   case 3: {
      if(dig_input[2]==digit[2])
      {
       check=check+1;
      }
      break;
     }
   case 4: {
      if(dig_input[3]==digit[3])
      {
       check=check+1;
      }
      break;
     }
  }
}
delay(10);
if(i==3)
{
  ans();
}
}

void display(int a) //Display function
{
switch(a)
{ 
  case 1:{
    lcd_data('*');
    delay(100);
    digit[i]=1;
    code_check();
    break;
    }
  case 2:{
    lcd_data('*');
    delay(100);
    digit[i]=2;
    code_check(); 
    break;
    }
  case 3:{
    lcd_data('*');
    delay(100);
    digit[i]=3;
    code_check();
    break;
    }
  case 4:{
    lcd_data('*');
    delay(100);
    digit[i]=4;
    code_check();
    break;
    }
  case 5:{
    lcd_data('*');
    delay(100);
    digit[i]=5;
    code_check();
    break;
    }
  case 6:{
    lcd_data('*');
    delay(100);
    digit[i]=6;
    code_check();
    break;
    }
  case 7:{
    lcd_data('*');
    delay(100);
    digit[i]=7;
    code_check();
    break;
    }
  case 8:{
    lcd_data('*');
    delay(100);
    digit[i]=8;
    code_check();
    break;
    }
  case 9:{
    lcd_data('*');
    delay(100);
    digit[i]=9;
    code_check();
    break;
    }
  case 0:{
    lcd_data('*');
    delay(100);
    digit[i]=0;
    code_check();
    break;
    }
}
}

void check_col1()
{
row1=row2=row3=row4=1;
row1=0;
if(col1==0)
display(1);
row1=1;
row2=0;
if(col1==0)
display(4);
row2=1;
row3=0;
if(col1==0)
display(7);
row3=1;
row4=0;
if(col1==0)
{
  row4=1;
}
}

void check_col2()
{
row1=row2=row3=row4=1;
row1=0;
if(col2==0)
display(2);
row1=1;
row2=0;
if(col2==0)
display(5);
row2=1;
row3=0;
if(col2==0)
display(8);
row3=1;
row4=0;
if(col2==0)
display(0);
row4=1;
}

void check_col3()
{
row1=row2=row3=row4=1;
row1=0;
if(col3==0)
display(3);
row1=1;
row2=0;
if(col3==0)
display(6);
row2=1;
row3=0;
if(col3==0)
display(9);
row3=1;
row4=0;
if(col3==0)
{
  row4=1;
}
}


void check_password_col1()
{
row1=row2=row3=row4=1;
row1=0;
if(col1==0)
dig_input[k]=1;
row1=1;
row2=0;
if(col1==0)
dig_input[k]=4;
row2=1;
row3=0;
if(col1==0)
dig_input[k]=7;
row3=1;
row4=0;
if(col1==0)
{
  row4=1;
}
}

void check_password_col2()
{
row1=row2=row3=row4=1;
row1=0;
if(col2==0)
dig_input[k]=2;
row1=1;
row2=0;
if(col2==0)
dig_input[k]=5;
row2=1;
row3=0;
if(col2==0)
dig_input[k]=8;
row3=1;
row4=0;
if(col2==0)
{
  dig_input[k]=0;
  row4=1;
}
}


void check_password_col3()
{
row1=row2=row3=row4=1;
row1=0;
if(col3==0)
dig_input[k]=3;
row1=1;
row2=0;
if(col3==0)
dig_input[k]=6;
row2=1;
row3=0;
if(col3==0)
dig_input[k]=9;
row3=1;
row4=0;
if(col3==0)
{
  row4=1;
}
}

void pass_set()
{
row1=row2=row3=row4=0;
while(col1==1 && col2==1 && col3==1);
for(i=0;i<4;i++)
{
  k=i;
  delay(50);
  lcd_cmd(0xc4+i);
  delay(100);
  row1=row2=row3=row4=0;
  while(col1==1 && col2==1 && col3==1);
  row1=row2=row3=row4=0;
  if(col1==0)
  check_password_col1();
  else
   if(col2==0)
   check_password_col2();
   else
    if(col3==0)
    check_password_col3();
  lcd_data('*');
  delay(50);
}
}

void main()
{
int e,j=0,count=1;
col1=col2=col3=1;
//FOR PASSWoRD INPUT
do
{
  lcd_cmd(0x01);  //Clear LCD screen
  lcd_cmd(0x81);  
  lcd("ENTER PASSWORD:");
  pass_set();
  for(e=0;e<4;e++)
  dig_input_recheck[e]=dig_input[e];
  lcd_cmd(0x01);
  lcd("CONFIRM PASSWORD:");
  pass_set();
  for(e=0;e<4;e++)
  {
   if(dig_input_recheck[e]==dig_input[e])
   j++;
  }
  if(j<4)
  {
   lcd_cmd(0x01);
   lcd_cmd(0x85);
   lcd("PASSWORD");
   lcd_cmd(0xC2);
   lcd("NOT MATCH");
   delay(300);
  }
}
while(j<4);
    
while(count<4) //Code input and check
{
  lcd_cmd(0x01); 
  lock_output=0;
  lcd_cmd(0x82);  
  lcd("ENTER PASSWORD");
  check=0;
  row1=row2=row3=row4=0;
  while(col1==1 && col2==1 && col3==1);
  for(i=0;i<4;i++)
  {
   delay(100);
   lcd_cmd(0xc4+i);
   row1=row2=row3=row4=0;
   while(col1==1 && col2==1 && col3==1);
   row1=row2=row3=row4=0;
   if(col1==0)
   check_col1();
   else
    if(col2==0)
    check_col2();
    else
     if(col3==0)
     check_col3();
  }
  count++;
  delay(1);   
}

if(count==4)
{
  lcd_cmd(0x01);
  lcd_cmd(0x86);
  lcd("SORRY");
  lcd_cmd(0xc1);
  lcd("NO MORE TRIALS");
  while(1);
}
}