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 / Topics / Help me to the correct the errors in this program for automatic toll collection

Help me to the correct the errors in this program for automatic toll collection

|

Microcontroller › 8051 › Help me to the correct the errors in this program for automatic toll collection

  • This topic has 2 replies, 3 voices, and was last updated 9 years, 4 months ago by Ashutosh Bhatt.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • March 7, 2016 at 1:48 pm #4344
    Sherin
    Participant
    //RX PIN 10  (P3_0)      //RFID(EM-18 MODULE)
    //TX PIN 11 (P3_1)
    int user1amt=45, user2amt=50,user3amt=70,amounttodisplay;
    int k1,k2;
    char cardletter;//rfid variable
    //lcd connections
    sbit LCD_RS at P2_3_bit;
    sbit LCD_EN at P2_2_bit;
    sbit LCD_D4 at P2_1_bit;
    sbit LCD_D5 at P2_0_bit;
    sbit LCD_D6 at P2_4_bit;
    sbit LCD_D7 at P2_5_bit;
    //motor
    sbit motor11 at P2_7_bit;
    sbit motor12 at P2_6_bit;
    //KEYPAD CONNECTIONS
    #define R1 P1.F0  //pin 1
    #define R2 P1.F1  //pin 2
    #define R3 P1.F2  //pin 3
    #define R4 P1.F3  //pin 4
    #define C1 P1.F4  //pin 13
    #define C2 P1.F5  //pin 14
    #define C3 P1.F6  //pin 15
    int key=12;
    void keydelay(void);
    void keypadinit(void);
    void keycheck(void);
    void card1(void);
    void card2(void);
     void card3(void);
    void rfid(void);
    void forwardmotor(void) ;
    void stopmotor(void);
    void nobalance(void);
    void balance(void);
    void lcdstart(void);
    void main() 
    {
    keypadinit();
    uart1_init(9600);
    lcdstart();   // Write text in first row
    stopmotor();
    while (1)
    {
    rfid();
    }
    }
    void rfid(void)
    {
      if (UART1_Data_Ready())
     {
    cardletter = UART1_Read();
    card1();
    card2();
     card3();
    }
    }
    void card1(void)  //card no.1000699A58BB(PRINTED NO.10539512)
    {
    if(cardletter=='6')
    {
    while(!(UART1_Data_Ready()));
    cardletter = UART1_Read();
    if(cardletter=='C')
    { 
    if(user1amt>49) {user1amt= user1amt-50;
     amounttodisplay= user1amt;
     balance();
     forwardmotor();
     }
    else
     {
    nobalance();
    keycheck();k1=key; Lcd_Chr(2, 3, k1+0x30);
    keycheck();k2=key; Lcd_Chr(2, 4, k2+0x30);
    user1amt=user1amt + k1*10 +k2;
     amounttodisplay= user1amt;
     balance();
     }}}}
     void card2(void) //card no.1000699A58BB(PRINTED NO.10539512)
    {
    if(cardletter=='1')
    {
    while(!(UART1_Data_Ready()));
    cardletter = UART1_Read();
    if(cardletter=='C')
    {
     
    if(user2amt>49) {user2amt= user2amt-50;
     amounttodisplay= user2amt;
     balance();   forwardmotor();
     }
    else
     {
    nobalance();
    keycheck();k1=key; Lcd_Chr(2, 3, k1+0x30);
    keycheck();k2=key; Lcd_Chr(2, 4, k2+0x30);
    user2amt=user2amt + k1*10 +k2;
     amounttodisplay= user2amt;
     balance();
     }}}}
     void card3(void)//card no.1000699A58BB(PRINTED NO.10539512)
    {
    if(cardletter=='D')
    {
    while(!(UART1_Data_Ready()));
    cardletter = UART1_Read();
    if(cardletter=='E')
    {
    if(user3amt>49) {user3amt= user3amt-50;
     amounttodisplay= user3amt;
     balance();   forwardmotor();
     }
    else
     {
    nobalance();
    keycheck();k1=key; Lcd_Chr(2, 3, k1+0x30);
    keycheck();k2=key; Lcd_Chr(2, 4, k2+0x30);
    user3amt=user3amt + k1*10 +k2;
     amounttodisplay= user3amt;
     balance();
     }}}}
     void balance(void)
    {
    Lcd_Cmd(_LCD_CLEAR);    Lcd_Out(1,1,"THANK YOU USER");
    Lcd_Out(2,1,"BAL ");
    Lcd_Chr_cp((amounttodisplay/100)+0x30);
    Lcd_Chr_cp(((amounttodisplay/10)%10)+0x30);
    Lcd_Chr_cp((amounttodisplay%10)+0x30);
    }
    void nobalance(void)
    {
     Lcd_Cmd(_LCD_CLEAR);  Lcd_Out(1,1,"less balance");
     Lcd_Out(2,1,"please recharge"); Delay_ms(500);
     Lcd_Cmd(_LCD_CLEAR);   Lcd_Out(1,1,"ENTER AMOUNT");
    }
    void forwardmotor(void)
    {
     motor11=1; motor12=0;    Delay_ms(500);
     stopmotor(); Delay_ms(3000);
     motor11=0; motor12=1;    Delay_ms(500);   stopmotor();
    }
     
     
    void stopmotor(void)
    {
     motor11=0; motor12=0;
    }
    void keycheck(void)
    {
    key=12;
    do
    {
    C1=0;C2=1;C3=1;
    if(R1==0) {key=1;}
    if(R2==0) {key=4;}
    if(R3==0) {key=7;}
    //if(R4==0) {key=10;}
    C1=1;C2=0;C3=1;
    if(R1==0) {key=2;}
    if(R2==0) {key=5;}
    if(R3==0) {key=8;}
    if(R4==0) {key=0;}
    C1=1;C2=1;C3=0;
    if(R1==0) {key=3;}
    if(R2==0) {key=6;}
    if(R3==0) {key=9;}
    //if(R4==0) {key=11;}
    }while(key==12);
    delay_ms(300);
    }
    void lcdstart(void)
    {
      Lcd_Init();                    // Initialize Lcd
                  // Clear display
      Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
      Lcd_Out(1,6,"haii");                 // Write text in first row
      delay_ms(500);
       Lcd_Cmd(_LCD_CLEAR);               // Clear display
    }
    void keypadinit(void)
    {
    C1=1; C2=1;C3=1;   //pull up
    R1=1; R2=1;R3=1;R3=1;    //pull up
    }
     
    September 23, 2016 at 12:32 pm #14150
    GANEEV SINGH
    Participant

    Hi Sherin

    Please specify what kind of errors are you getting in this code. Also try searching out similar projects on EG's web-portal.

    September 26, 2016 at 8:47 am #14160
    Ashutosh Bhatt
    Participant

    post your errors………..

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • To couple or decouple February 10, 2026
  • ANOTHER OLD PROJECT REDO February 10, 2026
  • analog logic of shmidt trigger bjt circuit February 10, 2026
  • Buffer design? February 10, 2026
  • XLR splitter to mono. February 10, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 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