Guest User

Untitled

a guest
Oct 19th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. void loop(){
  2.   int count = 0;
  3.   while(count < 30)
  4.   {
  5.     count++;
  6.     float value = readval();
  7.     Serial.println(value);  
  8.   }
  9.   while(true){
  10.   };
  11.  
  12. }
  13.  
  14.  
  15. float readval()
  16. {
  17. int byt=0;
  18. float val=0;
  19. float tot=0;
  20.   //function reads a value from the SD card values are stored as character floats with two dp and seperated with either a space or a new line, carriage return.
  21.   while(byt != 10 && byt != 32 )
  22.   {
  23.     //read character    
  24.     byt = (myFile.read());
  25.     //find begining of value
  26.    
  27.     //check for character ending
  28.     if(byt != 13 && byt != 10 && byt != 32)
  29.     {
  30.       //check for decimal place
  31.       if(byt != 46)
  32.       {
  33.         val = byt-48;
  34.         tot *= 10;
  35.         tot += val;
  36.       }
  37.     else if(byt == 46)
  38.       {
  39.         byt = (myFile.read());
  40.         val = byt - 48;
  41.         val /= 10;
  42.         tot += val;
  43.         byt = (myFile.read());
  44.         val = byt - 48;
  45.         val /= 100;
  46.         tot += val;
  47.       }
  48.     }
  49.    
  50.   }
  51.  
  52.   return tot;
  53. }
Add Comment
Please, Sign In to add comment