We’re conducting a static tensile test to calibrate our setup of a breadboard, Arduino Uno, and Gobetwino/Arduino software. I tried following the template available through the Gobetwino sample files to create a log of the data input from analog channel 1. We’re getting really strange values that appear to be random.
Programming is not my forte and before we begin troubleshooting our circuitry, I’m hoping to eliminate any errors in the code.
// This sketch demonstrates the use of the Gobetwino commandtypes LGFIL and CPFIL
int serInLen = 25;
char serInString[25];
int logValue1=0;
int result;
int xPin = A1;
void setup()
{
// Setup serial comm. Initialize random function.
Serial.begin(9600);
// Use the CPTEST copy file command to make a copy of a new empty logfile
Serial.println("#S|CPTEST|[]#");
readSerialString(serInString,1000);
pinMode(xPin, INPUT);
// There ought to be a check here for a non 0 return value indicating an error and some error handeling
}
void loop()
{
//Create some random values to log to a file on the PC. This could be sensor readings or whatever
//but for this example it's just 3 random values
logValue1= analogRead(xPin);
logData(logValue1);
delay(500);
}
// Send the LOGTEST command to Gobetwino the 3 random values are seperated by semicolons
void logData( int value1)
{
char buffer[5];
Serial.print("#S|LOGTEST|[]#");
Serial.print(itoa((value1), buffer, 10));
Serial.println("]#");
readSerialString(serInString,1000);
// There ought to be a check here for a non 0 return value indicating an error and some error handeling
}
//read a string from the serial and store it in an array
//you must supply the array variable - return if timeOut ms passes before the sting is read
void readSerialString (char *strArray,long timeOut)
{
long startTime=millis();
int i;
while (!Serial.available()) {
if (millis()-startTime >= timeOut) {
return;
}
}
while (Serial.available() && i < serInLen) {
strArray[i] = Serial.read();
i++;
}
}
Here’s an image of the data outputted to the Excel file:
Thank you so much for any and all help!
-Kinza