my goal is to make a scrolling 4 channel data graph using a tft display. Got the display test programs working with my leonardo but having programming problems, stuck using arrays. I plan on using an array for each data channel’s y position, shifting the data one channel to the left each update.
BUT I can’t get my array test debug program to work! I keep getting errors that the array was not defined in this scope in my serial.print commands. Is there a problem using serial.print with arrays??
here is my test program:
void setup() {
int ch1[6] = {1,2,3,4,5,6}; //this will be data channel 1
int ch2[6] = {11,12,13,14,15,16}; //this will be data channel 2
int ch3[6] = {21,22,23,24,25,26}; //this will be data channel 3
int ch4[6] = {31,32,33,34,35,36}; //this will be data channel 4
Serial.begin(9600);
while (!Serial) ; // while the serial stream is not open, do nothing:
uint16_t time = millis();
time = millis() - time;
Serial.println(time, DEC); //checking to make sure serial is working
delay(500);
}
void loop(){
Serial.println (""); // serial print intiation values each loop
Serial.print (“i=0”);
Serial.print (" ch1[0]=");
Serial.print (ch1[0]);
Serial.print (" ch2[0]=");
Serial.print (ch2[0]);
Serial.print (" ch3[0]=");
Serial.print (ch3[0]);
Serial.print (" ch4[0]=");
Serial.print (ch4[0]);
delay(1000);
drawData(); //shifts data left by one in arrays
delay(5000);
}
void drawData (){ // move data left then get and draw new data
for(int i=0; i<5; i++) { // 0-5 columns, old data left on right
Serial.println(“i=”);
Serial.print(i);
ch1*=ch1[i+1];*
- Serial.print(“ch1=”);*
_ Serial.print(ch1*);_
_ ch2=ch2[i+1];
Serial.print(“ch2=”);
Serial.print(ch2);
ch3=ch3[i+1];
Serial.print(“ch3=”);
Serial.print(ch3);
ch4=ch4[i+1];
Serial.print(“ch4=”);
Serial.print(ch4);
delay(1000);
}
}
[/color]*_
and the ERROR report:
arrayTest_02.ino: In function ‘void loop()’:
arrayTest_02:21: error: ‘ch1’ was not declared in this scope
arrayTest_02:23: error: ‘ch2’ was not declared in this scope
arrayTest_02:25: error: ‘ch3’ was not declared in this scope
arrayTest_02:27: error: ‘ch4’ was not declared in this scope
arrayTest_02.ino: In function ‘void drawData()’:
arrayTest_02:37: error: ‘ch1’ was not declared in this scope
arrayTest_02:40: error: ‘ch2’ was not declared in this scope
arrayTest_02:43: error: ‘ch3’ was not declared in this scope
arrayTest_02:46: error: ‘ch4’ was not declared in this scope
arrayTest_02.ino: At global scope:
arrayTest_02:67: error: expected declaration before ‘}’ token