Go Down

Topic: 'byte index' redeclared as different kind of symbol error (Read 71 times) previous topic - next topic

nguyenpt

Hi guys.
Yesterday, I complied this program and it run well. Now, I'm rebuilting it and some errors occurt.
Can you tell me how to fix that?
I cannot understand why same code but not same result.
Many thanks.

Code: [Select]

char inData[24];
byte index;
boolean started = false;
boolean ended = false;

void setup()
{
Serial.begin(9600);
Serial.println("Temperature & Humidity");
}

void loop()
{
  while(Serial.available() > 0)
  {
char aChar = Serial.read();
if(aChar == '<')
{
    started = true;
    index = 0;
    inData[index] = '\0';
}
else if(aChar == '>')
{
    ended = true;
}
else if(started)
{
    inData[index] = aChar;
    index++;
    inData[index] = ',';
}
  }

  if(started && ended)
  {
// Use the value
if(inData[0] == 'T')
{
   inData[0] = ' ';
   int windVal = atoi(inData);
           Serial.println(" ");
   Serial.print("Temp:");
           Serial.print(inData);
           Serial.print("C");
           Serial.println(" ");
}
else if(inData[0] == 'H')
     {
   inData[0] = ' ';
           int temp = atoi(inData);
   Serial.println(" ");
           Serial.print("Humidity:");
           Serial.print(inData);
           Serial.print("%");
           Serial.println(" ");
     }

started = false;
ended = false;

index = 0;
inData[index] = '\0';
  }
}

AWOL

I compiled your code, and got the following error message
Code: [Select]
Sketch uses 1726 bytes (5%) of program storage space. Maximum is 32256 bytes.
Global variables use 257 bytes (12%) of dynamic memory, leaving 1791 bytes for local variables. Maximum is 2048 bytes.
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.

Go Up