#define ON 1 #define OFF 0 char my_array[4]; int distance; c = readchar(); // or whatever function you have to read a bytes from the UART if (c == 'R') { my_array[0] = readchar(); my_array[1] = readchar(); my_array[2] = readchar(); my_array[3] = 0; distance = atoi(my_array); if (distance > 6) set_led (ON); else set_led (OFF); } |