Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. nodebug void Task3 (void *data)
  2. {
  3. /* Add a third Task to read ADC 1
  4. /* Clear the previour value inside the TOWER
  5. /* Normailize the [min, max] value of ADC [14 to 0]
  6. /* Dispaly the value Inside the TOWER
  7. /* Delay the task */
  8.     auto UBYTE err;
  9.  
  10.  
  11.  
  12.    auto char display[64];
  13.    int IRsensor;
  14.    int scaled;
  15.  
  16.     for(;;){
  17.       IRsensor = anaIn(1);
  18.       sprintf(display, "%d", IRsensor);
  19.        scaled = (float)((IRsensor - 1535) * 14 / 464);
  20.        scaled = (scaled>14) ? 14 : (scaled < 0) ? 0 : scaled;
  21.        DisplayTower();
  22.        DispStr(61, (6+scaled), display);
  23.        OSTimeDly(40);
  24.    }
  25.  
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement