title: how to read data in uart and execute a loop at the same time?
body: <p>my program is racing game. The problem is I want the enemy cars to move even when I don't press any key for UART to receive.</p>
  <p>When it reaches the key reading instruction(Serial.read), it does not execute any other instruction like, the enemy speed function, which allows moving the enemy tanks.</p>
  <p>how can I execute that function even if I don't write any letter in the uart?</p>
  <pre><code>#include &quot;tm4c123gh6pm.h&quot;
  #include &lt;stdint.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;time.h&gt;
  #include &lt;math.h&gt;
  #include &lt;string.h&gt;
  #include &quot;tivaduino.h&quot;
  #include &quot;Nokia5110.h&quot;
  
  //library
  
  uint8_t HardwareSerial0::read(void){
      uint8_t datoRx;
      
      while(UART0_FR_R &amp; 0x10==0x10); 
      
  
  //UART0_FR_R is in 1 if transmission buffer is full (no data is sent). if not, data can be sent to the buffer and it sends to TIVA
  
      datoRx = (uint8_t)UART0_DR_R;
      return datoRx;
  
  }
  </code></pre>
  <p>//one option that i was thinking was using UART_FR_TXFE in &quot;read&quot;</p>
  <pre><code>//main program
   while (1) {
  
  
  //is responsible for moving enemy cars to the far left and then disappear
  
  Nokia5110_enemy_speed (positionk1, positionk2, positionk3, positionk4, positionk5,
               positionh1, positionh2, positionh3, positionh4, positionh5); 
  
  
  //read a key on the uart (defined to be w, a, s, d)
  char_key = Serial.read ();
  
  sprintf (key, &quot;% c&quot;, char_key); `//convert char_key into string`
  
  
  if ((h &lt;24) &amp;&amp; (h&gt; = 0)) {// as long as x remains on the map
  
     if ((strcmp (key, &quot;w&quot;) == 0) &amp;&amp; (h&gt; 0)) {
  
  Nokia5110_clean_cart (k, h);
  h = h-8;
          Nokia5110_drawing_cart (k, h);
      }
       if ((strcmp (key, &quot;s&quot;) == 0) &amp;&amp; (h &lt;16)) {
  Nokia5110_clean_cart (k, h);
         h = h + 8;
     
        Nokia5110_drawing_cart (k, h);
      }
  if ((strcmp (key, &quot;d&quot;) == 0) &amp;&amp; (k &lt;78)) {
      Nokia5110_clean_cart (k, h);
         k = k + 6;
     
        Nokia5110_drawing_cart (k, h);
      }
  if ((strcmp (key, &quot;a&quot;) == 0) &amp;&amp; (k&gt; 0)) {
       Nokia5110_clean_cart (k, h);
         k = k-6;
      
       Nokia5110_drawing_cart (k, h);
      }
  
    }
  
   
  }
  </code></pre>