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 / microcontroller coin counter with IR sensor

microcontroller coin counter with IR sensor

|

Microcontroller › 8051 › microcontroller coin counter with IR sensor

  • This topic has 1 reply, 2 voices, and was last updated 13 years, 9 months ago by AJISH ALFRED.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • March 30, 2012 at 5:10 am #4765
    akmal
    Participant

     

    hi there

    I m working on coin counter project which can count the no. of coin entering in a boc. I am using at89c51,infrared led and a transistor and lcd for displaying no of counts.

     

     

     

     

     

     

    after i make a connection, my LCD show this results. There's no display on it. Im use this code "C Language"

     

    #include<reg51.h>

     

     

    void lcdcmd (unsigned char value);

    void lcddata (unsigned char value);

    void lcdready();

    void display(unsigned char z);

    void MSDelay (unsigned int itime);

     

    sfrldata = 0x90;

    sbit rs = P2^0;

    sbit rw = P2^1;

    sbit en = P2^2;

    sbit busy = P1^7;

    sbit sen5 = P2^4;

    sbit sen10 = P2^5;

    sbit sen20 = P2^6;

    sbit sen50 = P2^7;

     

    void main()

    {

                unsigned int a;

                unsigned int b;

                unsigned int c;

                unsigned int e;

     

                unsigned int ao;

                unsigned int bo;

                unsigned int co;

                unsigned int eo;

     

                lcdcmd(0x38);

                lcdcmd(0x0E);

                lcdcmd(0x01);

                lcdcmd(0x06);

               

                lcdcmd(0x80);

                lcddata('5');

                lcddata('c');

        

                lcdcmd(0x84);

                lcddata('1');

                lcddata('0');

                lcddata('c');

     

                lcdcmd(0x89);

                lcddata('2');

                lcddata('0');

                lcddata('c');

     

                lcdcmd(0x8D);

                lcddata('5');

                lcddata('0');

                lcddata('c');

     

                a = 1;

                b = 1;

                c = 1;

                e = 1;

     

                while(1)

                {

                            sen5 = 1;

                            sen10 = 1;

                            sen20 = 1;

                            sen50 = 1;

     

                            while(sen5 == 0)

                            {

                                        ao = a++;

                                        lcdcmd(0xC0);

                                        display (ao);

                                        MSDelay(100);

                            }

                            while(sen10 == 0)

                            {

                                        bo = b++;

                                        lcdcmd(0xC4);

                                        display (bo);

                                        MSDelay(100);

                            }

                            while(sen20 == 0)

                            {

                                        co = c++;

                                        lcdcmd(0xC9);

                                        display (co);

                                        MSDelay(100);

                            }

                            while(sen50 == 0)

                            {

                                        eo = e++;

                                        lcdcmd(0xCD);

                                        display(eo);

                                        MSDelay(100);

                            }

                }

    }

     

     


    void lcdcmd (unsigned char value)     

    {

                lcdready();

                ldata = value;

                rs = 0;

                rw = 0;

                en = 1;

                MSDelay(1);

                en = 0;

                return;

    }

     


    void lcddata (unsigned char value)     

    {

                lcdready();

                ldata = value;

                rs = 1;

                rw = 0;

                en = 1;

                MSDelay(1);

                en = 0;

                return;

    }

     

    void lcdready()

    {

                busy = 1;

                rs = 0;

                rw = 1;

                while (busy == 1)

                {

                            en = 0;

                            MSDelay (1);

                            en = 1;

                }

                return;

    }

     

    void display(unsigned char z)

    {

                unsigned char x,d1,d2;

     

                x = z / 10;

                d1 = z % 10;

                d2 = x % 10;

     

                lcddata(d2 + 0x30);

                lcddata(d1 + 0x30);

    }

     


    void MSDelay (unsigned int itime)    

    {

                unsigned int i,j;

                for (i = 0; i<itime; i++)

                            for (j = 0; j<1275; j++);

    }

     

    can anyone find the problem to fix this error??

    April 25, 2012 at 1:31 pm #7544
    AJISH ALFRED
    Participant

    try the code after changing your lcdready() function like the following

     

    void lcdready()

    {

      //          busy = 1;

                rs = 0;

                rw = 1;

      //          while (busy == 1)

      //          {

                            en = 0;

                            MSDelay ( 100 );

                            en = 1;

      //          }

                return;

    }

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

RSS Recent Posts

  • Buffer design? February 9, 2026
  • ANOTHER OLD PROJECT REDO February 9, 2026
  • BPF February 9, 2026
  • To couple or decouple February 9, 2026
  • Op amp shock February 9, 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