SixPathSage
Newbie level 2
I need my LCD to display Queue="number" , "number" starts at 0
1) "number" count up by 1 pressing button A // (PORTAbits.RA1==0);
2) "number" count down by 1 pressing button B // (PORTCbits.RC1==0);
Please help..
1) "number" count up by 1 pressing button A // (PORTAbits.RA1==0);
2) "number" count down by 1 pressing button B // (PORTCbits.RC1==0);
Please help..
HTML:
void lcd_init(void)
{
TRISD = 0x00;
PORTD = 0x00; // PORTD is connected to LCD data pin
LCD_EN = 0;
LCD_RS = 0; // Select LCD for command mode
LCD_WR = 0; // Select LCD for write mode
Delay10KTCYx(250); // Delay a total of 1 s for LCD module to
Delay10KTCYx(250); //
Delay10KTCYx(250); //
Delay10KTCYx(250); // finish its own internal initialisation
/* The data sheets warn that the LCD module may fail to initialise properly when
power is first applied. This is particularly likely if the Vdd
supply does not rise to its correct operating voltage quickly enough.
It is recommended that after power is applied, a command sequence of
3 bytes of 30h be sent to the module. This will ensure that the module is in
8-bit mode and is properly initialised. Following this, the LCD module can be
switched to 4-bit mode.
*/
lcd_write_cmd(0x33);
lcd_write_cmd(0x32);
lcd_write_cmd(0x28); // 001010xx ?Function Set instruction
// DL=0 :4-bit interface,N=1 :2 lines,F=0 :5x7 dots
lcd_write_cmd(0x0E); // 00001110 ?Display On/Off Control instruction
// D=1 :Display on,C=1 :Cursor on,B=0 :Cursor Blink on
lcd_write_cmd(0x06); // 00000110 ?Entry Mode Set instruction
// I/D=1 :Increment Cursor position
// S=0 : No display shift
lcd_write_cmd(0x01); // 00000001 Clear Display instruction
Delay1KTCYx(20); // 20 ms delay
}
unsigned int i; /* 16 bit data type, range 0 to 65,535 */
unsigned char j; /* 8 bit data type, range 0 to 255 */
void main(void)
{
// Do not remove these as well=============
ADCON1 = 0x0F; // Configure PORTA to be digital I/O
CMCON = 0x07;
// ========================================
// Your MAIN program Starts here: =========
TRISA = 0b11111111;
TRISC = 0b11111111;
lcd_init(); // Initialise LCD module
LCD_RS = 1; // Select LCD for character data mode
Delay1KTCYx(1); // 1 ms delay
while(1)
{
lcd_write_cmd(0x80); // Move cursor to line 1 position 1
lcd_write_data(0x51); // write "Q" to LCD
lcd_write_data(0x55); // write "U" to LCD
lcd_write_data(0x45); // write "E" to LCD
lcd_write_data(0x55); // write "U" to LCD
lcd_write_data(0x45); // write "E" to LCD
lcd_write_data(0x3D); // write "=" to LCD
//while(1); //stop here for now
}
}