How can i convert char from UART to int in mikroC ?
My below code to loop the number of times according to the character send from uart, does not work, can anybody help ?
My below code to loop the number of times according to the character send from uart, does not work, can anybody help ?
Rich (BB code):
void main(){
unsigned char txt[2];
int y,rot;
char on[10]; // char table to store received string
int intme;
trisb=0x00;
portb=0x00;
UART1_Init(9600);
// Check if character is ready for reading and read it.
if (UART1_Data_Ready() == 1) {
on[0] = UART1_Read(); // read one character from uart
on[1] = '\0'; // insert terminating zero
}
for(rot=0; rot<=atoi(on ); rot++)
{
PORTB=0b00010000; delay_ms(200);
PORTB=0b00001000; delay_ms(200);
}
}