Expected Initializer before 'int' Error

We are trying to mimic a mood ring effect onto a Teddy Bear by using RGB leds and sensors while using the adafruit Flora.
We have the code and have been modify it and have had a few successes but are currently stuck because we keep getting the same error. Which is that expected initializer should be before 'int'.

//TMP36 Pin Variables 
int temperaturePin = 0; //input: the analog pin the TMP36 is connected
//RGB LED pins
int led DigitalOne[]= {9,10,12};//output: the three digital pins of the RGB LED
int Red Pin 9;
9 = int temperature 60;
int green Pin 10; 
10 = int temperature = 60;
int Blue Pin 12;
12 = int temperature = 60;

const int ON= HIGH;//(255)
const int OFF= LOW; //(0)
const int DIM= 100;

//predefined Colors 
const int RED[]= {
  255,0,0}; 
const int DARKGREEN[]={
  0,100,0};
const int LIGHTBLUE[]={
  135,206,250};
const int BLUEVIOLET[]={
  138,48,226};
const int DARKORANGE[]={
  255,140,0}; 
const int WHITE[]={
  255,255,255};
const int BLACK[]={
  0,0,0};

void setup()
{
  // initialize serial communication with computer:
  Serial.begin(9600);                   
  // initialize all the temperature pin to 0: 
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;          
}
{
  for(int i=0;i< 3;i++);
  {
    pinMode (ledDigitalOne[i],INPUT) ;//SET THE RGB LED PINS AS OUTPUTS
  }
  Serial.begin(9600); // start the serial connection with the battery 
}
void loop ()
{
  float celsius = get Voltage(1);//getting the voltage reading from the temp sensor
  celsius= ( celsius-.5)* 100; // converting 10mv per degree with 500 mv offset
  // to degrees (( voltage - 500 mv )*100)  
  float fahrenheit = (celsius * ( 9.0/ 5.0))=32.0;
  data[1]=(int) fahrenheit;  
}
Serial.println (newTemperature);// printing the result
delay(7000);// waiting 7 seconds to get a new result

//Set the three LEDs to any predefined color depending of the temperature in F

if ((newTemperature > 40) && (newTemperature <= 71)) { 
  setColor (ledDigitalOne, BLACK);
  Serial.println("BLACK");
}
else if ((newTemperature >= 72)&&(newTemperature <= 73)) {
  setColor(ledDigitalOne, WHITE);
  Serial.println("WHITE"); 
}
else if ((newTemperature >=74) && (newTemperature <= 75)){
  setColor(ledDigitalOne, DARKORANGE);
  Serial.println ("DARKORANGE");
} 
else if ((newTemperature>=76) && (newTemperature <= 77)){ 
  setColor (ledDigitalOne, BLUEVIOLET); 
  Serial.println("BLUEVIOLET"); 
} 
else if ((newTemperature>=78) && (newTemperature <= 79)){ 
  setColor (ledDigitalOne, LIGHTBLUE); 
  Serial.println("LIGHTBLUE");
}
else if ((newTemperature>=80) && (newTemperature <= 81)){
  setColor(ledDigitalOne, DARKGREEN); 
  Serial.println("DARKGREEN");
} 
else if ((newTemperature>=82) && (newTemperature <= 83)){
  setColor(ledDigitalOne, RED);
  Serial.println("RED");
}

float getVoltage int add (int pin)
{
  return (analogRead (pin) *. 004882813); 
  //converting from a 0to 1024 digital range 
  //to 0 to 5 volts (each 1 reading equals ~ 5 milivolts) 
}
// Function to set the color
void setColor (int* led, int *color){ 
  for (int i= 0; i<3;i++){
    digitalWrite (led[i], color[i]);
  }
}

// A version of setColor that allows for using const int colors
void setColor(int* led, const int*color){
  int tempColor[]= {
    color[0],color[1], color[2]  };
  setColor(led, tempColor);
}

very often it is just that we forgot a ";" at the end of a line...
but in your case i think it is because you often have two words as a variable name, something like:

int Red Pin 9;

this doesn't work, you need to have a variable name in just one word, something like:

int redPin = 9;

correct all those variable names and check if it works better...
:wink:

what is this

{
  for(int i=0;i< 3;i++);
  {
    pinMode (ledDigitalOne[i],INPUT) ;//SET THE RGB LED PINS AS OUTPUTS
  }
  Serial.begin(9600); // start the serial connection with the battery
}

between your setup() and your loop()? Is it working like you intended it? It seems you have code outside from any functions. It maybe be from the formatting, but maybe you can also check that out...
(ah, and CMD+T auto formats your code... :wink: )

Why are you using Serial.begin() twice?

Good luck!
=)

Need more info on the error.
Perhaps it is referring to this line?

return (analogRead (pin) *. 004882813);

where there is a space between the . and 0?

Also, not sure what you are doing here:
int Red Pin 9;
9 = int temperature 60;
int green Pin 10;
10 = int temperature = 60;
int Blue Pin 12;
12 = int temperature = 60;

That just looks messed up to me.

You don't have a type declared for readings or numReadings

  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;

or data[]

  data[1]=(int) fahrenheit;

or new Temperature:

Serial.println (newTemperature);// printing the result

Thank you so much for your help! We corrected a few errors but we are still getting the same issue.

 //predefined Colors 
const int RED[]= {255,0,0}; 
const int DARKGREEN[]={0,100,0};
const int LIGHTBLUE[]={135,206,250};
const int BLUEVIOLET[]={138,48,226};
const int DARKORANGE[]={255,140,0}; 
const int WHITE[]={255,255,255};
const int BLACK[]={0,0,0};

void setup()
{
  for(int i=0;i< 3;i++);
  {
    pinMode (ledDigitalOne[i],INPUT) ;//SET THE RGB LED PINS AS OUTPUTS
    pinMode (9, OUTPUT);// red led
    pinMode (10,OUTPUT); //green led
    pinMode (12,OUTPUT);// blue led 
  }
  Serial.begin(9600); // start the serial connection with the battery 
}
void loop ()
{
  float celsius = get Voltage(1);//getting the voltage reading from the temp sensor
  celsius= ( celsius-.5)* 100; // converting 10mv per degree with 500 mv offset
  // to degrees (( voltage - 500 mv )*100)  
  float fahrenheit = (celsius * ( 9.0/ 5.0))=32.0;
  data[1]=(int) fahrenheit;  
}
Serial.println (newTemperature);// printing the result
delay(7000);// waiting 7 seconds to get a new result

//Set the three LEDs to any predefined color depending of the temperature in F

if ((newTemperature > 40) && (newTemperature <= 71)) { 
  setColor (ledDigitalOne, BLACK);
  Serial.println("BLACK");
}
else if ((newTemperature >= 72)&&(newTemperature <= 73)) {
  setColor(ledDigitalOne, WHITE);
  Serial.println("WHITE"); 
}
else if ((newTemperature >=74) && (newTemperature <= 75)){
  setColor(ledDigitalOne, DARKORANGE);
  Serial.println ("DARKORANGE");
} 
else if ((newTemperature>=76) && (newTemperature <= 77)){ 
  setColor (ledDigitalOne, BLUEVIOLET); 
  Serial.println("BLUEVIOLET"); 
} 
else if ((newTemperature>=78) && (newTemperature <= 79)){ 
  setColor (ledDigitalOne, LIGHTBLUE); 
  Serial.println("LIGHTBLUE");
}
else if ((newTemperature>=80) && (newTemperature <= 81)){
  setColor(ledDigitalOne, DARKGREEN); 
  Serial.println("DARKGREEN");
} 
else if ((newTemperature>=82) && (newTemperature <= 83)){
  setColor(ledDigitalOne, RED);
  Serial.println("RED");
}

float getVoltage int add (int pin)
{
  return (analogRead (pin) *. 004882813); 
  //converting from a 0to 1024 digital range 
  //to 0 to 5 volts (each 1 reading equals ~ 5 milivolts) 
}
// Function to set the color
void setColor (int* led, int *color){ 
  for (int i= 0; i<3;i++){
    digitalWrite (led[i], color[i]);
  }
}

// A version of setColor that allows for using const int colors
void setColor(int* led, const int*color){
  int tempColor[]= {
    color[0],color[1], color[2]  };
  setColor(led, tempColor);
}

  for(int i=0; i< 3; i++);Remove the semi-colon at the end

Fix this:

add: byte ledDigitalOne[] = {9,10,12,};

    pinMode (ledDigitalOne[i], OUTPUT) ;//SET THE RGB LED PINS AS OUTPUTS
   // these are not needed
   // pinMode (9, OUTPUT);// red led
   // pinMode (10,OUTPUT); //green led
   // pinMode (12,OUTPUT);// blue led

and declare types for the other variables mentioned earlier.

Typo...

float celsius = get Voltage(1);

Should be...

float celsius = getVoltage(1);

And if you didn't notice, you have an extra closing brace ("}") that is causing your loop to only be 5 lines long.

FWIW,

Brad
KF7FER

Nothing much wrong then ........

We used all of your suggestions, and thank you we appreciate it, but it's still giving us the same error. Here's the new code.

  void setup()
{
  for(int i=0;i< 3;i++)

    byte ledDigitalOne [] = {9, 10, 12};
    pinMode (ledDigitalOne[i],INPUT) ;  //SET THE RGB LED PINS AS OUTPUTS
    pinMode (9, OUTPUT);// red led
    pinMode (10,OUTPUT); //green led
    pinMode (12,OUTPUT);// blue led 
  }
  Serial.begin(9600); // start the serial connection with the battery 
}
void loop ()
{
const int (255,0,0);  //red
const int (0,100,0);  //dark green
const int (135,206,250);  //light blue
const int (138,48,226);  //blue violet
const int (255,140,0);   //dark orange
const int (255,255,255);  //white
const int (0,0,0);     //black

  float celsius = get Voltage(1);//getting the voltage reading from the temp sensor
  celsius= ( celsius-.5)* 100; // converting 10mv per degree with 500 mv offset
  // to degrees (( voltage - 500 mv )*100)  
  float fahrenheit = (celsius * (9.0/ 5.0))=32.0;
  data[1]=(int) fahrenheit;  
}
Serial.println (newTemperature);// printing the result
delay(7000);// waiting 7 seconds to get a new result

//Set the three LEDs to any predefined color depending of the temperature in F

if ((newTemperature > 37 ) && (newTemperature <= 37.2)) { 
  setColor (ledDigitalOne, BLACK);
  Serial.println("BLACK");
}
else if ((newTemperature >= 39)&&(newTemperature <= 39.2)) {
  setColor(ledDigitalOne, WHITE);
  Serial.println("WHITE"); 
}
else if ((newTemperature >=35.4) && (newTemperature <= 35.6)){
  setColor(ledDigitalOne, DARKORANGE);
  Serial.println ("DARKORANGE");
} 
else if ((newTemperature>=38.6) && (newTemperature <= 38.8)){ 
  setColor (ledDigitalOne, BLUEVIOLET); 
  Serial.println("BLUEVIOLET"); 
} 
else if ((newTemperature>=35) && (newTemperature <= 35.2)){ 
  setColor (ledDigitalOne, LIGHTBLUE); 
  Serial.println("LIGHTBLUE");
}
else if ((newTemperature>=37.4) && (newTemperature <= 37.6)){
  setColor(ledDigitalOne, DARKGREEN); 
  Serial.println("DARKGREEN");
} 
else if ((newTemperature>=39.4) && (newTemperature <= 39.6)){
  setColor(ledDigitalOne, RED);
  Serial.println("RED");
}
float getVoltage int add (int pin)
{
  return (analogRead (pin) *.004882813); 
  //converting from a 0 to 1024 digital range 
  //to 0 to 5 volts (each 1 reading equals ~ 5 milivolts) 
}
// Function to set the color
void setColor (int* led, int *color){ 
  for (int i= 0; i<3;i++)
  { digitalWrite (led[i], color[i])}
}

// A version of setColor that allows for using const int colors
void setColor(int* led, const int*color){
  int tempColor[]= { color[0],color[1], color[2]};
  setColor(led, tempColor);
}

No you didn't, you just put more errors in. WTF is this:-

const int (255,0,0);  //red
const int (0,100,0);  //dark green
const int (135,206,250);  //light blue
const int (138,48,226);  //blue violet
const int (255,140,0);   //dark orange
const int (255,255,255);  //white
const int (0,0,0);     //black

There is no variable name and you can't assign a variable to a value like this. In python this would be called a tuplet but this is not python it is C.

You need to sort out in your head what you want to do first. Only then can you write code to do it.

There is lots wrong with this code besides this point.

There is so much wrong with that code it is hard to begin.
I suspect they you didn't write it and are trying to convert something from one language to another without understanding either language.

Here is a version that compiles at least, although I would be surprised if it did what you want.

 int ledDigitalOne[] = {9, 10, 12}; // define as global so you can use it in any function
 
 void setup()
{
  for(int i=0;i< 3; i++) {
    pinMode (ledDigitalOne[i], INPUT);  //SET THE RGB LED PINS AS OUTPUTS
  }
    pinMode (9, OUTPUT);// red led
    pinMode (10,OUTPUT); //green led
    pinMode (12,OUTPUT);// blue led 
  Serial.begin(9600); // start the serial connection with the battery 
}

int RED[] = {255,0,0};  //red
int DARKGREEN[] = {0,100,0};  //dark green
int LIGHTBLUE[] = {135,206,250};  //light blue
int BLUEVIOLET[] = {138,48,226};  //blue violet
int DARKORANGE[] = {255,140,0};   //dark orange
int WHITELIGHT[] = {255,255,255};  //white
int BLACKLIGHT[] = {0,0,0};     //black

void loop()
{
int RED[] = {255,0,0};  //red
int DARKGREEN[] = {0,100,0};  //dark green
int LIGHTBLUE[] = {135,206,250};  //light blue
int BLUEVIOLET[] = {138,48,226};  //blue violet
int DARKORANGE[] = {255,140,0};   //dark orange
int WHITELIGHT[] = {255,255,255};  //white
int BLACKLIGHT[] = {0,0,0};     //black

  float celsius = getVoltage(1);//getting the voltage reading from the temp sensor
  celsius= ( celsius-.5)* 100; // converting 10mv per degree with 500 mv offset
  // to degrees (( voltage - 500 mv )*100)  
  float newTemperature = (celsius * (9.0/ 5.0)) + 32.0; 

Serial.println (newTemperature);// printing the result
delay(7000);// waiting 7 seconds to get a new result

//Set the three LEDs to any predefined color depending of the temperature in F

if ((newTemperature > 37 ) && (newTemperature <= 37.2)) { 
  setColor (ledDigitalOne, BLACKLIGHT);
  Serial.println("BLACK");
}
else if ((newTemperature >= 39)&&(newTemperature <= 39.2)) {
  setColor(ledDigitalOne, WHITELIGHT);
  Serial.println("WHITE"); 
}
else if ((newTemperature >=35.4) && (newTemperature <= 35.6)){
  setColor(ledDigitalOne, DARKORANGE);
  Serial.println ("DARKORANGE");
} 
else if ((newTemperature>=38.6) && (newTemperature <= 38.8)){ 
  setColor (ledDigitalOne, BLUEVIOLET); 
  Serial.println("BLUEVIOLET"); 
} 
else if ((newTemperature>=35) && (newTemperature <= 35.2)){ 
  setColor (ledDigitalOne, LIGHTBLUE); 
  Serial.println("LIGHTBLUE");
}
else if ((newTemperature>=37.4) && (newTemperature <= 37.6)){
  setColor(ledDigitalOne, DARKGREEN); 
  Serial.println("DARKGREEN");
} 
else if ((newTemperature>=39.4) && (newTemperature <= 39.6)){
  setColor(ledDigitalOne, RED);
  Serial.println("RED");
}
}

float getVoltage(int pin)
{
  return (analogRead (pin) * 0.004882813); 
  //converting from a 0 to 1024 digital range 
  //to 0 to 5 volts (each 1 reading equals ~ 5 milivolts) 
}
// Function to set the color
void setColor(int led[], int color[]){ 
  for (int i= 0; i<3;i++)
  { 
    digitalWrite (led[i], color[i]);
  }
}

// A version of setColor that allows for using const int colors // so give it another ****ing name
void setColor2(int led[], int color[]){
  int tempColor[]= { color[0],color[1], color[2]};
  setColor(led, tempColor);
}

Now never post such a mess again. Learn the basic syntax of the language. It is hard enough getting the code to do what you want without having to fight the syntax.

You have not! Your latest attempt is a mess.
With a little more cut & pasting, see the notes below, I think this will work.

byte ledDigitalOne [] = {9, 10, 12}; // three PWM pins?
// need something like this:
const byte color[] = {
255,0,0, //red = 0
0,100,0, //dark green = 3
135,206,250, //light blue = 6
138,48,226, //blue violet = 9
255,140,0, //dark orange = 12
255,255,255, //white = 15
0,0,0, //black = 18
};
byte RED = 0;
byte GREEN = 3;
byte LIGHTBLUE = 6;
byte BLUEBVIOLET = 9;
byte DARKORANGE = 12;
byte WHITE = 15;
byte BLACK = 18;
float celsius;
float fahrenheit
int data[2];
float newTemperature;
void setup()
{
for(int i=0;i< 3;i++){
pinMode (ledDigitalOne[i],OUTPUT) ; //SET THE RGB LED PINS AS OUTPUTS
}
Serial.begin(9600); // start the serial connection with the battery 
}
void loop ()
{
float celsius = getVoltage(1);//getting the voltage reading from the temp sensor
celsius= ( celsius-.5)* 100; // converting 10mv per degree with 500 mv offset
// to degrees (( voltage - 500 mv )*100) 
float fahrenheit = (celsius * (9.0/ 5.0))=32.0;
data[1]=(int) fahrenheit; 

Serial.println (newTemperature);// printing the result
delay(7000);// waiting 7 seconds to get a new result

//Set the three LEDs to any predefined color depending of the temperature in F

if ((newTemperature > 37 ) && (newTemperature <= 37.2)) { 
//setColor (BLACK);
analogWrite ( ledDigitalOne [0], color[BLACK]);
analogWrite ( ledDigitalOne [1], color[BLACK+1]);
analogWrite ( ledDigitalOne [2], color[BLACK+2]);
Serial.println("BLACK");
}
else if ((newTemperature >= 39)&&(newTemperature <= 39.2)) {
//setColor( WHITE);
analogWrite ( ledDigitalOne [0], color[WHITE]);
analogWrite ( ledDigitalOne [1], color[WHITE+1]);
analogWrite ( ledDigitalOne [2], color[WHITE+2]);
Serial.println("WHITE"); 
}
// etc for the other colors
// this could probably be a function to save a few lines. I don't use functions myself, everything islined.

else if ((newTemperature >=35.4) && (newTemperature <= 35.6)){
setColor(DARKORANGE);
Serial.println ("DARKORANGE");
} 
else if ((newTemperature>=38.6) && (newTemperature <= 38.8)){ 
setColor (BLUEVIOLET); 
Serial.println("BLUEVIOLET"); 
} 
else if ((newTemperature>=35) && (newTemperature <= 35.2)){ 
setColor (LIGHTBLUE); 
Serial.println("LIGHTBLUE");
}
else if ((newTemperature>=37.4) && (newTemperature <= 37.6)){
setColor(DARKGREEN); 
Serial.println("DARKGREEN");
} 
else if ((newTemperature>=39.4) && (newTemperature <= 39.6)){
setColor(RED);
Serial.println("RED");
}

} // end loop

float getVoltage int add (int pin)
{
return (analogRead (pin) * .004882813); 
//converting from a 0 to 1024 digital range 
//to 0 to 5 volts (each 1 reading equals ~ 5 milivolts) 
}
 { digitalWrite (led[i], color[i])}

Shouldn't there be a colon at the end of the digitalWrite statement ?

Shouldn't there be a colon at the end of the digitalWrite statement ?

No, only half of one :slight_smile:

Yeah, that's what I meant. (did I say colon ? Where's my cofee?)

Yeah, that's what I meant

I know you did, hence my jocular reply !
To make it clear to anyone reading this that does not understand what we are talking about, it should be a semi-colon.

;

smiley wink to you too.

No, only half of one

A hemi-colon? 8)