buzzed
Newbie level 6
I want to increment a counter for Line2 and display it on LCD when the pushbutton is pressed. It displays correctly, but when I press the button it shows different characters like this(||). When I place a cursor to the 9 of Line2 and pressed the button it displays symbol(||).
Code to display the LCD as:
code for Pushbutton is as:
main function as:
Code to display the LCD as:
Code:
#include <stdio.h>
#include <string.h>
extern unsigned char LIne1[32] = "Hello, World";
extern unsigned char Line2[32] = "9567 ";
void dispset_titl(void)
{
unsigned char n;
unsigned char dsp_buf;
lcd_l1(0x00); //for postion of line1
for (n=0 ;n<16 ;n++) {
dsp_buf = Line1[n];
lcd_dout(dsp_buf);
}
lcd_l2(0x40); //for postion of line2
for (n=0 ;n<16 ;n++) {
dsp_buf = LIne2[n];
lcd_dout(dsp_buf);
}
}
void lcd_cout(unsigned char ccod)
{
unsigned char ccod_msb;
unsigned char ccod_lsb;
ccod_msb = ccod / 0x10;
ccod_lsb = ccod & 0x0F;
P7 = ccod_msb;
P7 = ccod_msb | 0x20;
delay_micro(2);
P7 = ccod_msb;
delay_micro(2);
P7 = ccod_lsb;
P7 = ccod_lsb | 0x20;
delay_micro(2);
P7 = ccod_lsb;
delay_micro(50);
}
void lcd_dout(unsigned char dcod)
{
unsigned char dcod_msb;
unsigned char dcod_lsb;
dcod_msb = dcod / 0x10;
dcod_lsb = dcod & 0x0F;
P7 = dcod_msb | 0x10;
P7 = dcod_msb | 0x30;
delay_micro(2);
P7 = dcod_msb | 0x10;
delay_micro(2);
P7 = dcod_lsb | 0x10;
P7 = dcod_lsb | 0x30;
delay_micro(2);
P7 = dcod_lsb | 0x10;
delay_micro(50);
}
code for Pushbutton is as:
Code:
int counter = 0;
int temp;
void Increment_button(void)
{
if (button == 1) { //when button is on
temp=counter++;
lcd_dout(temp);
}
}
main function as:
Code:
#include <stdio.h>
#include <string.h>
unsigned char button= 0;
void main(void)
{
while (1)
{
panel();
WDT_Reset();
Increment_button();
}
Last edited: