Thread: Help With library counter programs

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    That might work...
    Code:
    if (p3.0 == 0 && p3.1 == 1)
    ...if that zero was an "oh", and that one was an "el"


    Quzah.
    Hope is the first step on the road to disappointment.

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    ...if that zero was an "oh", and that one was an "el"
    Quzah.
    Some embedded systems identify bits on hardware ports that way... Can't remember exactly where but I have seen this before.

    In any case, even if the variable names are bogus... the concept is right.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by CommonTater View Post
    Some embedded systems identify bits on hardware ports that way... Can't remember exactly where but I have seen this before.

    In any case, even if the variable names are bogus... the concept is right.
    Hm...

    C and the 8051 - Google Books

    Maybe something like that table, column four? C wouldn't let you use a number as a variable name, which is why I mentioned it. But I suppose if you were writing your own hardware specific compiler you could. But I'm guessing it's really just a way to reference it for discussion, rather than an actual variable name.

    edit - a few seconds and a search engine confirms my suspicions:
    Code:
    /*
    	Program:Lcd4b.C
    	Patchup file:Lcd4ba.c
    	Author: Vineet Kulkarni
    	Date:06-07-2000
    	Modified:07-07-2000
    	Language: C + assembly
    	LCD test program, to be used with Mini51 evaluation/prototyping board
    	LCD connections:
    		p2.0 to p2.3 are connected to 4 MSBits of LCD databus
    		p2.4 is connected to EN of LCD (1 means LCD selected)
    		p2.5 is connected to A0 of LCD (0 means command, 1 means data)
    		WR of LCD is connected to Ground, so we can never read LCD status
    
    	This program has functions to initialize LCD and display a
    	string on it.
    	Here the LCD is port driven and used in 4 bit interface.
    */
    They use the .# for reference, but the actual code does not:
    Code:
    void display_lcd(char arr[32]) {
    
    // displays first 16 characters in the string on line 1 and
    // remaining 16 characters on 2nd line
    // assumed 16 X 2 display
    	unsigned char count, tempchar;
    
    	lcd_cmd(0x80);
    	for(count=0;count<16;count++) { // first line
    		if(arr[count]) {
    			tempchar = arr[count] ;
    			lcd_dat(tempchar);
    		}
    		else return;
    	}
    	lcd_cmd(0xc0);		//addrs for second line
    	for(count=16;count<32;count++) {
    		if (arr[count]) {
    			tempchar = arr[count] ;
    			lcd_dat(tempchar);
    		}
    		else return;
    	}
    }

    Quzah.
    Last edited by quzah; 08-12-2011 at 04:53 PM.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Aug 2011
    Posts
    3

    Thank you for the help so far

    I fiddled with making a C program for this that works on the computer. It works heh. But I do not know how to get it to work with 8051. The biggest problem I am having how do I get the contents of the X and Y variable to display on the LCD? here is the program

    Code:
    void main(void)
    {
    int P30; //first photo eye
    int P31; //second photo eye
    int x=0; //entyer count
    int y=0; //exit count
    do
    	{
    printf("\nwhich photo eye broke first? 1 or 2\n");
    scanf("%d", &P30);
    printf("\nwhich photo eye broke second\n");
    scanf("%d", &P31);
    
    //checking to see the order in which the photo eyes are broken the photo eyes will be tied to 
    //high so when they go low this will increment the right count based on which photo eye went
    //low first
    if(P30==1&&P31==2)
    			x++;
    		else if(P30==2&&P31==1)
    			y++;
    printf("\n%d people entered\n", x);
    printf("\n%d people exited\n", y);
    	} while(x>=0);
    }
    Last edited by ssotek; 08-15-2011 at 04:57 PM. Reason: FIX ERRORS

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by ssotek View Post
    I do not know how to get it to work with 8051. The biggest problem I am having how do I get the contents of the X and Y variable to display on the LCD?
    I assume that whoever gave you this assignment also gave you some instructions on the 8051. Go read them. Failing that, use the internet: "displaying on the 8051 lcd" + your search engine of choice = answers.


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Odd/Even counter.
    By fyoung91 in forum C++ Programming
    Replies: 3
    Last Post: 08-11-2010, 12:02 PM
  2. Replies: 1
    Last Post: 11-09-2009, 07:03 AM
  3. Page File counter and Private Bytes Counter
    By George2 in forum Tech Board
    Replies: 0
    Last Post: 01-31-2008, 03:17 AM
  4. Replies: 19
    Last Post: 01-12-2006, 11:04 AM
  5. Could I create my own library to include in programs?
    By EliasK in forum C++ Programming
    Replies: 1
    Last Post: 03-22-2003, 08:24 AM