Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
char on[10]; // char table to store received string
int intme;
// 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
}
intme = atoi(on);
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);
}
}
Then how can i convert , if i have to send a character like "100" to uart ?
on[7] = UART1_Read_Text(output, "m", 255);
void main(){
unsigned char txt[2];
unsigned char output[7];
int y,rot;
char on[28]; // char table to store received string
int intme;
trisb=0x00;
portb=0x00;
UART1_Init(9600);
while(1){
while (!UART1_Data_Ready()); // wait for UART character in buffer
UART1_Read_Text(output, "m", 255); // read one character from uart
y=strlen(output);
on[y]=output;
on[y+1]='\0'; // insert terminating zero
for(rot=0; rot<=atoi(on)-1; ++rot)
{
PORTB=0b00010000; delay_ms(200);
PORTB=0b00001000; delay_ms(200);
}
}
}
is it something wrong with it ? , its not working
void main(){
char output[7];
int i,rot;
trisb=0x00;
portb=0x00;
UART1_Init(9600);
while(1){
while (!UART1_Data_Ready()); // wait for UART character in buffer
// Initialize string with all '\0'
for(i=0; i<7; i++){
output[i] = '\0';
}
UART1_Read_Text(output, "m", 255); // read input from uart
for(rot=0; rot<=atoi(output)-1; ++rot)
{
PORTB=0b00010000; delay_ms(200);
PORTB=0b00001000; delay_ms(200);
}
}
}