Implementing a 4 bit Counter using an 8051 and Interfacing it to an LCD
...................................................................................................................................

#pragma SMALL DB OE
#include
#include "io.h"

/* P0, P1, P2 and P3 are predefined port names and are bit addressable */

sbit reset = P0^4; /* bit 4 of Port 0 */
sbit up_down = P0^5;
sbit load = P0^6;
sbit Start_LCD = P0^7; /* bit 7 of Port 3 */

/* Delay function */
void delay() {

        int i, j;

        for(i=0; i<1000; i++)
                for(j=0; j<100; j++)
                        i = i + 0;
}

/* Function to output the decimal value of the count on the LCD */
void PrintInt(unsigned char i) {
       char ch[4];

       /* Write code to convert the count to a string value and use the
           PrintString function provided in io.c */

        PrintString(ch);
}

void main(void) {

        unsigned char count = 0;

        InitIO();  /* Initialize the LCD */
        while (1) {
                if (Start_LCD == 1) {
                        ClearScreen();
                        PrintString("Ready...");
                        delay();
                }
                else if (reset == 1) {

                        /* Output 0 on the LCD */

                }
                else if (load == 1) {

                       /* Output the current value of Datain on the LCD */

                }
                else {
                        /* Check the Up/Down pin for 1 or 0 count up or down
                           accordingly. Display each value on the LCD */
               }
      }
}

The program will be used to control a simple 4-bit up-down counter, capable of counting from 0 to 15. At each step the count should be displayed in decimal format on the LCD.
The 4 bit counter has the following functionality:
       a.        Reset : when high resets the counter dataout to ``0000''
       b.        Updown : decides whether the counter counts up or down.
       c.        Load : makes the counter count from the 4 bit input Datain
       d.        Datain : which is a 4 bit input count

Click here to Download the Program...
· Home
· 8051 Forum
· Active Topics
· 8051 Free Projects
· Blog
· Top 10
· Datasheets
· Electronic Tutorials
· Electronic Projects
· 8051 Tutorials
· 8051 Course
· 8051 Code Library
· Visual Basic for mC
· 8051 Programmer
· Assembler/IDE
· Products
· Ebooks
· Supporting Tools
· Tag Cloud
· Guest Book
· Contact Me
· Privacy policy

8051 Microcontroller Projects, free ebooks, project codes, AVR Projects, 8051 tutorials, electronic projects, ECE CSE BE final year projects, Embedded systems, AVR codes, embedded technology, LCD Interfacing tutorial,final year project ideas project downloads, engineering projects, Examples projects, 8051 Libraries, 8052, Microcontroller, Microprocessor, 8085, 8051 codes, PCB designing, Project Kits, kit