Page 1 of 1

Help me in this code

Posted: 05 Aug 2010 20:09
by Eng_Bandar
my project if I send letter G from computer to pic led will on and this is my code

Code: Select all

char data;
void main()
{ 
trisb=0; // all portb are output
UART1_Init(9600); // speed is 9600
while(1)
{
if(UART1_Data_Ready()==1)
{ // when receiving data
data = UART1_Read(); // read data and store it in variable
if(data=='G') {portb.f0=1;}
}
}
}
my comiler is MikroC Pro 3.8 when I build the code errors come to me and these errors in attachments

Re: Help me in this code

Posted: 05 Aug 2010 20:21
by p.erasmus
It seems that the variable data you are using is a keyword and reserved for the
C language or the mE compiler !!
I changed it to data_1 and the project compiles properly
Please read the language reference manual to inform your self about
the restricted words

Code: Select all

char data_1;
void main()
{
trisb=0; // all portb are output
UART1_Init(9600); // speed is 9600
while(1)
{
if(UART1_Data_Ready()==1)
{ // when receiving data
data_1 = UART1_Read(); // read data and store it in variable
if(data_1=='G') {portb.f0=1;}
}
}
}

Re: Help me in this code

Posted: 06 Aug 2010 15:26
by Eng_Bandar
^^^^^^^^^
Thank you for your helping