Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void loop(){
- int count = 0;
- while(count < 30)
- {
- count++;
- float value = readval();
- Serial.println(value);
- }
- while(true){
- };
- }
- float readval()
- {
- int byt=0;
- float val=0;
- float tot=0;
- //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.
- while(byt != 10 && byt != 32 )
- {
- //read character
- byt = (myFile.read());
- //find begining of value
- //check for character ending
- if(byt != 13 && byt != 10 && byt != 32)
- {
- //check for decimal place
- if(byt != 46)
- {
- val = byt-48;
- tot *= 10;
- tot += val;
- }
- else if(byt == 46)
- {
- byt = (myFile.read());
- val = byt - 48;
- val /= 10;
- tot += val;
- byt = (myFile.read());
- val = byt - 48;
- val /= 100;
- tot += val;
- }
- }
- }
- return tot;
- }
Add Comment
Please, Sign In to add comment