CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Want to display last value on LCD Screen

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
deltatech



Joined: 22 Apr 2006
Posts: 87

View user's profile Send private message

Want to display last value on LCD Screen
PostPosted: Mon Sep 19, 2011 10:10 am     Reply with quote

Hi. I have problem which may be simple for CCS Gurus but I am stuck.

I have two Buttons Button A and Button B.

I am displaying on the LCD Screen the number of times these buttons are pressed.

What I want to do is to be able to display the last value that was displayed on the LCD.

For example if I press Button A 3 times, and then stop and press it again I want to display on the LCD that when I started again it was 3.

Similarly if I pressed Button A 5 Times and then pressed Button B.

I want display on the LCD Screen that the last time I changed direction the value on the LCD was 5 etc.

I have CCS 4.120 compiler.
PIC16F877 with a 10MHz crystal.

Code:

#include "G:\LCD-CLOCK\PIC-C-CODE\STEP-MOTOR\main.h"
#include <lcd.c>

void main()
{

float y=0 ;
float Z=0 ;
lcd_init();
   
// Clear the LCD.
lcd_gotoxy(0, 1);
printf(lcd_putc, "\f");
delay_ms(100);
lcd_gotoxy(1, 1);
printf(lcd_putc, "Number of Pulses");

while(1){

int i =0;
 
   if (!input(pin_A0)==1) {// If button A is Pressed
   y=y+1;
             
               output_b(0x01);
                   delay_ms( 50 );
               output_b(0x02);
                  delay_ms( 50 );
                output_b(0x04);
                  delay_ms( 50 );
                output_b(0x08);
                 delay_ms( 50 );
                 output_b(0x00);
                 
         }

if (!input(pin_A1)==1) {// If button B is Pressed
   y=y-1;
               output_b(0x08);
                   delay_ms( 50 );
               output_b(0x04);
                  delay_ms( 50 );
                output_b(0x02);
                  delay_ms( 50 );
                output_b(0x01);
                 delay_ms( 50 );
                  output_b(0x00);
             

   if (y<=0) y=0;
             }
 
lcd_gotoxy(7, 2);
 printf(lcd_putc, "%3.0f",y);
  }
}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group