When I try to store float variables in an array, I get a int values with a few decimal places after them. The code will work with int variables however, that is not what I need. So where is the number getting truncated?
#include <TextFinder.h>
TextFinder finder(Serial);
const int NUMBER_OF_FIELDS = 28; // how many comma-separated fields we expect
int fieldIndex = 0; // the current field being received
float values[NUMBER_OF_FIELDS]; // array holding values for all the fields
void setup()
{
Serial.begin(57600); // Initialize serial port to send and receive at 57600 baud
}
void loop()
{
for(fieldIndex = 0; fieldIndex < 28; fieldIndex ++)
{
values[fieldIndex] = finder.getValue(); // get a numeric value
}
Serial.print( fieldIndex);
Serial.println(" fields received:");
for(int i=0; i < fieldIndex; i++)
{
Serial.println(values[i]);
}
fieldIndex = 0; // ready to start over
}
Variables I was using...
0,0.02,-0.01,9.82,2.0,0,1500,1500,1500,1000,1000,2000,0,0, 1000,1000,1000,1000,0,0,0,0,11.3,0\r\n
Any help would be great! thanks!