EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Replies / #include#include

#include#include

|

Microcontroller › 8051 › I have some problem regarding RFID madule interfacing….. › #include#include

September 24, 2014 at 9:44 am #12226
Rahul Ray
Participant
#include<reg51.h>
#include<string.h>
#include <intrins.h>
#define cmdport P3
#define dataport P2
sbit rs = P3^0;        //register select pin
sbit rw = P3^1;        //read write pin
sbit  e = P3^2;     //enable pin
sbit motor_pin = P0^7;
unsigned int data_out,temp;
unsigned char card_id[12];
code unsigned char RFID_1[]=”FE00458C2413″;
code unsigned char RFID_2[]=”4E007051B8D7″;
void Delay(unsigned int);
void Delay_servo(unsigned int);
void recieve()     //Function to recieve data serialy from RS232 
{
    unsigned char k;
     for(k=0;k<12;k++)
     { 
         while(RI==0); 
          card_id[k]=SBUF;
          RI=0;
    }
}
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 Delay(unsigned int ms)
//{
 // unsigned long int us = ms*1000;
  //while(us–)
 // {
   // _nop_();
  //}
//}
 
void Delay_servo(unsigned int us)
{
  while(us–)
  {
    _nop_();
  }
}
void lcdcmd(unsigned char item)    //Function to send command to LCD
{
rs= 0;
rw=0;
e=1;
dataport = item;
delay(10);
e=0;
delay(10);
}
void lcddata(unsigned char iitem)    //Function to send data to LCD
{
rs= 1;
rw=0;
e=1;
dataport = iitem;
delay(10);
e=0;
delay(10);
}
void lcd_init()
{
lcdcmd(0x38);
lcdcmd(0x0E);
lcdcmd(0x01);
}
//void lcd_string(char add,char *str)
void lcd_string(char *iitem)
{
int i;
//lcdcmd(add);
for(i=0;iitem!=’’;i++)
{
lcddata(iitem);
    }
}
void motor_forward()
{
  motor_pin = 0;
 do
  { //Turn to 0 degree
    motor_pin = 1;
    Delay_servo(30);
    motor_pin = 0;
    delay(100);
   //Turn to 90 degree
    motor_pin=1;
    Delay_servo(62);
    motor_pin=0;
    delay(100);
    //Turn to 180 degree
    motor_pin=1;
    Delay_servo(110);
    motor_pin=0;
    delay(100);
  }while(1);
}
void main()
{
    //unsigned char rec_data[12];
int l=12,i;
    TMOD=0x20;            //Enable Timer 1
    TH1=0XFD;
    SCON=0x50;
    TR1=1;
lcd_init();
lcdcmd(0x80);
lcd_string(“SWAP_THE_CARD:”);  // Triggering Timer 1
delay(100);
while(1)
    {
  recieve();
       lcdcmd(0xC1);        //Place cursor to second position of second line
         for(l=0;l<12;l++)
         { 
              lcddata(card_id[l]);
 delay(1000);
         }
i=0;
while(1)
{
i=strcmp(RFID_1,card_id);
if(i!=0)
{
lcdcmd(0x01);
lcdcmd(0x0E);
lcdcmd(0x80);
//lcddata(“MOVE MOTOR”);
lcd_string(“MOVE MOTOR”);
         motor_forward();
}
else
{
lcdcmd(0x01);
lcdcmd(0x0E);
lcdcmd(0x80);
delay(100);
//lcddata(“NO_MOVEMENT”);
lcd_string(“NO MOVEMENT”);
delay(1000);
}
 }
  
}
}
     
i here posted my code…………..due to the mismatching between RFID tag numbers,there is always showing the NO MOVEMENT of motor………………
i already mentioned the rfid tag number from hyperterminal in the above.
 
 
 
 
 
 
 

RSS Recent Posts

  • PIC KIT 3 not able to program dsPIC June 15, 2025
  • Siemens large industrial PLC parts June 15, 2025
  • Parts required for a personal project June 15, 2025
  • Cant log in to Easy PC forum June 15, 2025
  • Failure of polypropylene motor-run capacitors June 15, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise