Hello everyone, help me to correct this code ...
I have a syntax error but do not know why, I see nothing wrong with it.
MapLab compile in C18 lite
error line 12 (char keycodes[]={0,’#’,’0’,’*’,’-’,’9’,’8’,’7’,’-’,’6’,’5’,’4’,’-’,’3’,’2’,’1’,’-’};
)
I have a syntax error but do not know why, I see nothing wrong with it.
Code:
#include <p18cxxx.h>
#include <delays.h>
#pragma config PLLDIV = 5 // (20 MHz crystal)
#pragma config CPUDIV = OSC1_PLL2
#pragma config USBDIV = 2 // Clock source from 96MHz PLL/2
#pragma config FOSC = HSPLL_HS
#pragma config WDT = OFF
#pragma config LVP = OFF
char buf1[16]="KEYPAD TEST";
char buf2[16]="KEY: ";
char keycodes[]={0,’#’,’0’,’*’,’-’,’9’,’8’,’7’,
’-’,’6’,’5’,’4’,’-’,’3’,’2’,’1’,’-’};
unsigned short kp,ka,led=1,sw=1;
int delay=0;
char keypadread(void);
char scankey(void);
VOID main() {
ADCON1 |= 0x0F;
PORTA = TRISA = 0x00;
PORTB = TRISB = 0x00;
INTCON2 &= ~0x80; //conecta las resistencias pull-up al puerto B
lcd_init();
lcd_clear();
lcd_display(1,1,buf1);
Delay10KTCYx(250);
lcd_clear();
lcd_display(1,1,buf2);
do
{
kp=0;
do
{
kp = keypadread(); // Store key code in kp variable
Delay10KTCYx(12);
}while (!kp);
ka=keycodes[kp];
if(ka==’#’ && led<0x80) led=led<<1;
if(ka==’*’ && led>0x01) led=led>>1;
PORTD=led;
lcd_clear();
lcd_display(1,1,buf2);
lcd_char(ka); // Print key ASCII value on LCD
} while (1);
}
error line 12 (char keycodes[]={0,’#’,’0’,’*’,’-’,’9’,’8’,’7’,’-’,’6’,’5’,’4’,’-’,’3’,’2’,’1’,’-’};
)