hey i have a piece of code where I want to collect data.
I have minimized it so you can more easily help me to solve the problem.
code looks like this:
#include <SPI.h>
char test[0xFF]={
"input"};
char data[0xFF];
void setup() {
Serial.begin(9600);
}
void loop()
{
delay(1000);
strcpy(data,"data=1,2,3,4,5");
strcat(test,data);
Serial.println(test);
delay(1000);
}
The problem is that data = 1,2,3,4,5 duplicate the in each loop.
it should only be there once.
output:
inputdata=1,2,3,4,5
inputdata=1,2,3,4,5data=1,2,3,4,5
inputdata=1,2,3,4,5data=1,2,3,4,5data=1,2,3,4,5
inputdata=1,2,3,4,5data=1,2,3,4,5data=1,2,3,4,5data=1,2,3,4,5
inputdata=1,2,3,4,5data=1,2,3,4,5data=1,2,3,4,5data=1,2,3,4,5data=1,2,3,4,5
inputdata=1,2,3,4,5data=1,2,3,4,5data=1,2,3,4,5data=1,2,3,4,5data=1,2,3,4,5data=1,2,3,4,5
Expected output:
inputdata=1,2,3,4,5
inputdata=1,2,3,4,5
inputdata=1,2,3,4,5
inputdata=1,2,3,4,5
what am I doing wrong.