At present, I am using Arduino Due and I have connected several sensors.
Each sensor and module such as GPS worked well when operated in single operation.
However, when integrating the source, putting the gps value in the global variable 'FINAL_GPS_VALUE' does not cause the program to stop or display a value.
I don't know why.
Can anybody give me some advice?
(My final goal is to merge the variables into one to send all values to the master. )
#include <DueTimer.h>
String FINAL_GPS_VALUE;
bool GPS_VALUE_EMPTY = true;
const byte numChars = 40;
char receivedChars[numChars];
boolean newData = false;
void setup() {
Serial.begin(9600);
Serial1.begin(9600);
// put your setup code here, to run once:
Timer4.attachInterrupt(SENSOR_DISPLAY).start(1000000);
}
void loop() {
GPS_INFO_DISPLAY();
}
void SENSOR_DISPLAY(){
Serial.print("3.3V : ");
//Serial.print(InputVoltage3Result);
Serial.print(", 5V : ");
//Serial.print(InputVoltage5Result);
Serial.print(", SENSOR1 : ");
//Serial.println(maxErrTotalCount);
Serial.print(", GPS : ");
Serial.println(FINAL_GPS_VALUE);
}
void GPS_INFO_DISPLAY(){
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '
;
char endMarker = '\n';
char rc;
while (Serial1.available() > 0 && newData == false) {
rc = Serial1.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
if ((newData == true) ) {
if(receivedChars[3] == 'M'){
//Serial.print("GPS : ");
//Serial.println(receivedChars);
for(int i = 0 ; i < 40 ; i++){
FINAL_GPS_VALUE = receivedChars[i];
}
}
newData = false;
}
}