deltatech
Joined: 22 Apr 2006 Posts: 87
|
Want to display last value on LCD Screen |
Posted: Mon Sep 19, 2011 10:10 am |
|
|
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);
}
}
|
|
|