error: invalid conversion from 'volatile byte' to 'void (*)()'

I cant find any info on this error message can any one help please?

So the code use's a pump and a hall sensor and should run a pump up to max speed, if there is a blockage detected by the hall sensor the pump is re-ramped up to max speed of up to 3Ltr's/Min. The code isn't tested and may need some numbers changed.

The code

byte sensorInterrupt = 0;  // 0 = pin 2; 1 = pin 3
byte sensorPin       = 2;
int rpPin = 3;    // Rims Pump pin connected to digital pin 3


// The hall-effect flow sensor outputs approximately 4.5 pulses per second per
// litre/minute of flow.
float calibrationFactor = 4.5;

volatile byte pulseCount;  

float flowRate;
unsigned int flowMilliLitres;

unsigned long oldTime;



void setup() {
  
  { 
  // Initialize a serial connection for reporting values to the host
  Serial.begin(9600);
   
  
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  oldTime           = 0;

 {
  attachInterrupt(sensorInterrupt, pulseCount, FALLING);
  
 }

void loop() {
  // Ramp up from min to max in increments of 5 points:
  for (int RampValue = 0 ; RampValue <= 255; RampValue += 5) {
    // sets the value (range from 0 to 255):
    analogWrite(rpPin, RampValue);
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
  }
 
  if((millis() - oldTime) > 1000)    // Only process counters once per second
  { 
   
    detachInterrupt(sensorInterrupt);
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    oldTime = millis();
 
    flowMilliLitres = (flowRate / 60) * 1000;
    unsigned int frac;

    Serial.print(int(flowRate));  // Print the integer part of the variable
    Serial.print(".");             // Print the decimal point
   
    frac = (flowRate - int(flowRate)) * 10;
    Serial.print(frac, DEC) ;      // Print the fractional part of the variable

    // Print the number of litres flowed in this second
    Serial.print(" ");             // Output separator
    Serial.print(flowMilliLitres);
    
 
    {
    
         
    // Reset the pulse counter so we can start incrementing again
    pulseCount = 0;
    
    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  }
}

/**
 * Invoked by interrupt0 once per rotation of the hall-effect sensor. Interrupt
 * handlers should be kept as small as possible so they return quickly.
 */
void pulseCounter()

  // Increment the pulse counter
  pulseCount++;
}
{
 if (flowrate/60 >= 3)
   analogeWrite  (Rampvalue == 0)   
 
  
}

The error message

Arduino: 1.5.6-r2 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

RimsPumprunup.ino: In function 'void setup()':
RimsPumprunup:38: error: invalid conversion from 'volatile byte' to 'void ()()'
RimsPumprunup:38: error: initializing argument 2 of 'void attachInterrupt(uint8_t, void (
)(), int)'
RimsPumprunup:42: error: a function-definition is not allowed here before '{' token
RimsPumprunup:97: error: expected }' at end of input RimsPumprunup:97: error: expected }' at end of input

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

Can any one explain this please and point out any glaring errors too ?

TIA

Pesh

You seem to have a typo in attachInterrupt(sensorInterrupt, pulseCount, FALLING);

Shouldn't it be "pulseCounter"?

Bad idea to have variables and functions with nearly identical names.

...R

You should remove the { at line 21.

void setup() {
  
  {  //<------------------REMOVE THIS
  // Initialize a serial connection for reporting values to the host
  Serial.begin(9600);

Not just that, there are three '{' and only one '}' for setup()

So this code is copied from other sketches, i wanted to test the code and add to it if i proved it worked the code started out as

 #include <TFT.h>  // Arduino TFT library
#include <SPI.h>

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

// Specify the pins for the two counter reset buttons and indicator LED

byte sensorInterrupt = 0;  // 0 = pin 2; 1 = pin 3
byte sensorPin       = 2;

// The hall-effect flow sensor outputs approximately 4.5 pulses per second per
// litre/minute of flow.
float calibrationFactor = 4.5;

volatile byte pulseCount;  

float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitresA;
unsigned long totalMilliLitresB;

unsigned long oldTime;

void setup()
{
  TFTscreen.begin();
  TFTscreen.background(0,0,0);
  TFTscreen.stroke(255,255,255);
  TFTscreen.setTextSize(3);
 
 
  
  // Initialize a serial connection for reporting values to the host
  Serial.begin(9600);
   
  
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  totalMilliLitresA = 0.0;
  totalMilliLitresB = 0.0;
  oldTime           = 0;

  // The Hall-effect sensor is connected to pin 2 which uses interrupt 0.
  // Configured to trigger on a FALLING state change (transition from HIGH
  // state to LOW state)
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}

/**
 * Main program loop
 */
void loop()
{
  {
  }
  
  if((millis() - oldTime) > 1000)    // Only process counters once per second
  { 
    // Disable the interrupt while calculating flow rate and sending the value to
    // the host
    detachInterrupt(sensorInterrupt);
   
    
    // Because this loop may not complete in exactly 1 second intervals we calculate
    // the number of milliseconds that have passed since the last execution and use
    // that to scale the output. We also apply the calibrationFactor to scale the output
    // based on the number of pulses per second per units of measure (litres/minute in
    // this case) coming from the sensor.
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    
    // Note the time this processing pass was executed. Note that because we've
    // disabled interrupts the millis() function won't actually be incrementing right
    // at this point, but it will still return the value it was set to just before
    // interrupts went away.
    oldTime = millis();
    
    // Divide the flow rate in litres/minute by 60 to determine how many litres have
    // passed through the sensor in this 1 second interval, then multiply by 1000 to
    // convert to millilitres.
    flowMilliLitres = (flowRate / 60) * 1000;
    
    // Add the millilitres passed in this second to the cumulative total
    totalMilliLitresA += flowMilliLitres;
    totalMilliLitresB += flowMilliLitres;
  
    // During testing it can be useful to output the literal pulse count value so you
    // can compare that and the calculated flow rate against the data sheets for the
    // flow sensor. Uncomment the following two lines to display the count value.
   // Serial.print(pulseCount, DEC);
    //Serial.print("  ");
    
    // Write the calculated value to the serial port. Because we want to output a
    // floating point value and print() can't handle floats we have to do some trickery
    // to output the whole number part, then a decimal point, then the fractional part.
    unsigned int frac;
    
    // Print the flow rate for this second in litres / minute
    Serial.print(int(flowRate));  // Print the integer part of the variable
    Serial.print(".");             // Print the decimal point
    // Determine the fractional part. The 10 multiplier gives us 1 decimal place.
    frac = (flowRate - int(flowRate)) * 10;
    Serial.print(frac, DEC) ;      // Print the fractional part of the variable

    // Print the number of litres flowed in this second
    Serial.print(" ");             // Output separator
    Serial.print(flowMilliLitres);

    // Print the cumulative total of litres flowed since starting
    Serial.print(" ");             // Output separator
    Serial.print(totalMilliLitresA);
    Serial.print(" ");             // Output separator
    Serial.println(totalMilliLitresB);
    
    TFTscreen.stroke(255,255,255);
    TFTscreen.text("Flow:",0,0);
    if(int(flowRate) < 10)
    {
    
    }
    TFTscreen.text("",0,30),
    TFTscreen.print((int)flowRate);   // Print the integer part of the variable
    TFTscreen.text(".",0,30);             // Print the decimal point
    TFTscreen.print(frac, DEC) ;      // Print the fractional part of the variable
    TFTscreen.text(" L/Min",55,30);
    
    TFTscreen.text("",0,70);
    TFTscreen.print(int(totalMilliLitresA / 1000));
    TFTscreen.print("L");
    
    
    TFTscreen.text("",70,70);
    TFTscreen.print(int(totalMilliLitresB / 1000));
    TFTscreen.print("L");
    
    
  
    
    // Reset the pulse counter so we can start incrementing again
    pulseCount = 0;
    
    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  }
}

/**
 * Invoked by interrupt0 once per rotation of the hall-effect sensor. Interrupt
 * handlers should be kept as small as possible so they return quickly.
 */
void pulseCounter()
{
  // Increment the pulse counter
  pulseCount++;
}

Which kind of works the only problem i have with this is text over writing old text with out clearing the old text first.

so ive split this post in to two post coz its gettin a bit long so see below.

so continued from the post above

I added code from the fade sketch to make

#include <TFT.h>  // Arduino TFT library
#include <SPI.h>

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

// Specify the pins for the two counter reset buttons and indicator LED

byte sensorInterrupt = 0;  // 0 = pin 2; 1 = pin 3
byte sensorPin       = 2;

// The hall-effect flow sensor outputs approximately 4.5 pulses per second per
// litre/minute of flow.
float calibrationFactor = 4.5;

volatile byte pulseCount;  

float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitresA;
unsigned long totalMilliLitresB;

unsigned long oldTime;



int rppin = 3;           // the pin that the RimsPump is attached to
int pumpspeed = 0;    // how bright the LED is
int RampAmount = 5;    // how many points to fade the LED by

// the setup routine runs once when you press reset:




void setup() {
  // declare pin 9 to be an output:
  pinMode(rppin, OUTPUT);
{



  TFTscreen.begin();
  TFTscreen.background(0,0,0);
  TFTscreen.stroke(255,255,255);
  TFTscreen.setTextSize(3);
 
  pinMode(rppin, OUTPUT);
  
  // Initialize a serial connection for reporting values to the host
  Serial.begin(9600);
   
  
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  totalMilliLitresA = 0.0;
  totalMilliLitresB = 0.0;
  oldTime           = 0;

  // The Hall-effect sensor is connected to pin 2 which uses interrupt 0.
  // Configured to trigger on a FALLING state change (transition from HIGH
  // state to LOW state)
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  
  
}

void loop() {
  // put your main code here, to run repeatedly:

  if((millis() - oldTime) > 1000)    // Only process counters once per second
  { 
    // Disable the interrupt while calculating flow rate and sending the value to
    // the host
    detachInterrupt(sensorInterrupt);
   
    
    // Because this loop may not complete in exactly 1 second intervals we calculate
    // the number of milliseconds that have passed since the last execution and use
    // that to scale the output. We also apply the calibrationFactor to scale the output
    // based on the number of pulses per second per units of measure (litres/minute in
    // this case) coming from the sensor.
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    
    // Note the time this processing pass was executed. Note that because we've
    // disabled interrupts the millis() function won't actually be incrementing right
    // at this point, but it will still return the value it was set to just before
    // interrupts went away.
    oldTime = millis();
    
    // Divide the flow rate in litres/minute by 60 to determine how many litres have
    // passed through the sensor in this 1 second interval, then multiply by 1000 to
    // convert to millilitres.
    flowMilliLitres = (flowRate / 60) * 1000;
    
    // Add the millilitres passed in this second to the cumulative total
    totalMilliLitresA += flowMilliLitres;
    totalMilliLitresB += flowMilliLitres;
  
    // During testing it can be useful to output the literal pulse count value so you
    // can compare that and the calculated flow rate against the data sheets for the
    // flow sensor. Uncomment the following two lines to display the count value.
   // Serial.print(pulseCount, DEC);
    //Serial.print("  ");
    
    // Write the calculated value to the serial port. Because we want to output a
    // floating point value and print() can't handle floats we have to do some trickery
    // to output the whole number part, then a decimal point, then the fractional part.
    unsigned int frac;
    
    // Print the flow rate for this second in litres / minute
    Serial.print(int(flowRate));  // Print the integer part of the variable
    Serial.print(".");             // Print the decimal point
    // Determine the fractional part. The 10 multiplier gives us 1 decimal place.
    frac = (flowRate - int(flowRate)) * 10;
    Serial.print(frac, DEC) ;      // Print the fractional part of the variable

    // Print the number of litres flowed in this second
    Serial.print(" ");             // Output separator
    Serial.print(flowMilliLitres);

    // Print the cumulative total of litres flowed since starting
    Serial.print(" ");             // Output separator
    Serial.print(totalMilliLitresA);
    Serial.print(" ");             // Output separator
    Serial.println(totalMilliLitresB);
    
    TFTscreen.stroke(255,255,255);
    TFTscreen.text("Flow:",0,0);
    if(int(flowRate) < 10)
    {
    
    }
    TFTscreen.text("",0,30),
    TFTscreen.print((int)flowRate);   // Print the integer part of the variable
    TFTscreen.text(".",0,30);             // Print the decimal point
    TFTscreen.print(frac, DEC) ;      // Print the fractional part of the variable
    TFTscreen.text(" L/Min",55,30);
    
    TFTscreen.text("",0,70);
    TFTscreen.print(int(totalMilliLitresA / 1000));
    TFTscreen.print("L");
    
    
    TFTscreen.text("",70,70);
    TFTscreen.print(int(totalMilliLitresB / 1000));
    TFTscreen.print("L");
    
    
  
    
    // Reset the pulse counter so we can start incrementing again
    pulseCount = 0;
    
    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  }
}

/**
 * Invoked by interrupt0 once per rotation of the hall-effect sensor. Interrupt
 * handlers should be kept as small as possible so they return quickly.
 */
void pulseCounter()
{
  // Increment the pulse counter
  pulseCount++;
}

// set the brightness of pin 9:
  analogWrite(rppin, pumpspeed);

  // change the brightness for next time through the loop:
  pumpspeed = pumpspeed + RampAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (brightness == 0 || brightness
  }
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}

}

This get the error message
Arduino: 1.5.6-r2 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Build options changed, rebuilding all

Using library TFT in folder: C:\Program Files (x86)\Arduino\libraries\TFT

Using library SPI in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI (legacy)

C:\Program Files (x86)\Arduino\hardware\tools\avr\bin\avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega2560 -DF_CPU=16000000L -DARDUINO=156 -DARDUINO_AVR_MEGA2560 -DARDUINO_ARCH_AVR -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\mega -IC:\Program Files (x86)\Arduino\libraries\TFT\src -IC:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI C:\Users\Pete\AppData\Local\Temp\build131039157258798746.tmp\sketch_may13b.cpp -o C:\Users\Pete\AppData\Local\Temp\build131039157258798746.tmp\sketch_may13b.cpp.o

sketch_may13b.ino: In function 'void setup()':
sketch_may13b.ino:74: error: 'pulseCounter' was not declared in this scope
sketch_may13b.ino:79: error: a function-definition is not allowed here before '{' token
sketch_may13b.ino:197: error: expected `}' at end of input

Why do i get ": error: 'pulseCounter' was not declared in this scope" in one but not the other ?

Pesh

Im i missing some thing ?

the other errors in guessing are because i copied a { or a } from the other sketch and i have too many now

Im i missing some thing ?

Yes, go and count all the '{' characters, then count all the '}' characters. There are multiple places where you have missing or extra brackets. This was mentioned earlier in the thread yet the same errors are still present in your code.

EDIT: it seems you already know its the problem, yet you leave them in.

the other errors in guessing are because i copied a { or a } from the other sketch and i have too many now

Sorry thats because its the same code coped again, im not that concerned about { and } because i only need to add or delete them the bigger problem wich i cant explain is the error mesage in one and not the other its the same code as far as i can tell.

I dont want to seam dim or ignorant i just want to solve one problem at a time the first one listed is the

" error: 'pulseCounter' was not declared in this scope"

So why is this happening ?

Pesh

oh i will make the corections youve advised thanks for the help so far

Pesho77:
Sorry thats because its the same code coped again, im not that concerned about { and } because i only need to add or delete them the bigger problem wich i cant explain is the error mesage in one and not the other its the same code as far as i can tell.
I dont want to seam dim or ignorant i just want to solve one problem at a time the first one listed is the
" error: 'pulseCounter' was not declared in this scope"

Fix the incorrect brackets, and you'll find the pulseCounter error most probably goes away. Sometimes the error messages are not so obvious, and you need to inspect the surrounding code too.

The more i look at this the more confused i get, think i have a } for every { but im still getting an error message

#include <TFT.h>  // Arduino TFT library
#include <SPI.h>

// pin definition for the Uno
#define cs   10
#define dc   9
#define rst  8

// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

// Specify the pins for the two counter reset buttons and indicator LED

byte sensorInterrupt = 0;  // 0 = pin 2; 1 = pin 3
byte sensorPin       = 2;

// The hall-effect flow sensor outputs approximately 4.5 pulses per second per
// litre/minute of flow.
float calibrationFactor = 4.5;

volatile byte pulseCount;  

float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitresA;
unsigned long totalMilliLitresB;

unsigned long oldTime;



int rppin = 3;           // the pin that the RimsPump is attached to
int pumpspeed = 0;    // how bright the LED is
int RampAmount = 5;    // how many points to fade the LED by












// the setup routine runs once when you press reset:

void setup() {
  // declare pin 9 to be an output:
  pinMode(rppin, OUTPUT);




  TFTscreen.begin();
  TFTscreen.background(0,0,0);
  TFTscreen.stroke(255,255,255);
  TFTscreen.setTextSize(3);
 
  pinMode(rppin, OUTPUT);
  
  // Initialize a serial connection for reporting values to the host
  Serial.begin(9600);
   
  
  pinMode(sensorPin, INPUT);
  digitalWrite(sensorPin, HIGH);

  pulseCount        = 0;
  flowRate          = 0.0;
  flowMilliLitres   = 0;
  totalMilliLitresA = 0.0;
  totalMilliLitresB = 0.0;
  oldTime           = 0;

  // The Hall-effect sensor is connected to pin 2 which uses interrupt 0.
  // Configured to trigger on a FALLING state change (transition from HIGH
  // state to LOW state)
  attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  
  
}








void loop() {
  // put your main code here, to run repeatedly:

  if((millis() - oldTime) > 1000)    // Only process counters once per second
   
    // Disable the interrupt while calculating flow rate and sending the value to
    // the host
    detachInterrupt(sensorInterrupt);
   
    
    // Because this loop may not complete in exactly 1 second intervals we calculate
    // the number of milliseconds that have passed since the last execution and use
    // that to scale the output. We also apply the calibrationFactor to scale the output
    // based on the number of pulses per second per units of measure (litres/minute in
    // this case) coming from the sensor.
    flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
    
    // Note the time this processing pass was executed. Note that because we've
    // disabled interrupts the millis() function won't actually be incrementing right
    // at this point, but it will still return the value it was set to just before
    // interrupts went away.
    oldTime = millis();
    
    // Divide the flow rate in litres/minute by 60 to determine how many litres have
    // passed through the sensor in this 1 second interval, then multiply by 1000 to
    // convert to millilitres.
    flowMilliLitres = (flowRate / 60) * 1000;
    
    // Add the millilitres passed in this second to the cumulative total
    totalMilliLitresA += flowMilliLitres;
    totalMilliLitresB += flowMilliLitres;
  
    // During testing it can be useful to output the literal pulse count value so you
    // can compare that and the calculated flow rate against the data sheets for the
    // flow sensor. Uncomment the following two lines to display the count value.
   // Serial.print(pulseCount, DEC);
    //Serial.print("  ");
    
    // Write the calculated value to the serial port. Because we want to output a
    // floating point value and print() can't handle floats we have to do some trickery
    // to output the whole number part, then a decimal point, then the fractional part.
    unsigned int frac;
    
    // Print the flow rate for this second in litres / minute
    Serial.print(int(flowRate));  // Print the integer part of the variable
    Serial.print(".");             // Print the decimal point
    // Determine the fractional part. The 10 multiplier gives us 1 decimal place.
    frac = (flowRate - int(flowRate)) * 10;
    Serial.print(frac, DEC) ;      // Print the fractional part of the variable

    // Print the number of litres flowed in this second
    Serial.print(" ");             // Output separator
    Serial.print(flowMilliLitres);

    // Print the cumulative total of litres flowed since starting
    Serial.print(" ");             // Output separator
    Serial.print(totalMilliLitresA);
    Serial.print(" ");             // Output separator
    Serial.println(totalMilliLitresB);
    
    TFTscreen.stroke(255,255,255);
    TFTscreen.text("Flow:",0,0);
    if(int(flowRate) < 10)
}

{
  
    TFTscreen.text("",0,30),
    TFTscreen.print((int)flowRate);   // Print the integer part of the variable
    TFTscreen.text(".",0,30);             // Print the decimal point
    TFTscreen.print(frac, DEC) ;      // Print the fractional part of the variable
    TFTscreen.text(" L/Min",55,30);
    
    TFTscreen.text("",0,70);
    TFTscreen.print(int(totalMilliLitresA / 1000));
    TFTscreen.print("L");
    
    
    TFTscreen.text("",70,70);
    TFTscreen.print(int(totalMilliLitresB / 1000));
    TFTscreen.print("L");
    
    
  
    
    // Reset the pulse counter so we can start incrementing again
    pulseCount = 0;
    
    // Enable the interrupt again now that we've finished sending output
    attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
  }


/**
 * Invoked by interrupt0 once per rotation of the hall-effect sensor. Interrupt
 * handlers should be kept as small as possible so they return quickly.
 */
void pulseCounter()
{
  // Increment the pulse counter
  pulseCount++;
}

// set the pumpspeed of pin 3:
  analogWrite(rppin, pumpspeed);

  // change the brightness for next time through the loop:
  pumpspeed = pumpspeed + RampAmount;

  // reverse the direction of the fading at the ends of the fade:
  if (pumpspeed == 0 || pumpspeed
  {
  // wait for 30 milliseconds to see the dimming effect
  delay(30);
}

Can any one help please

TIA
Pesh

Everything after this:

// set the pumpspeed of pin 3:

is not in a function; it needs to be.

I've loaded your code into my text editor. You have NOT sorted out your }{ brackets. The opening bracket for setup() is on line 41 and my editor finds the closing bracket on line 187.

Don't come back here until you KNOW that my editor won't find another similar issue.

...R

Sorry om very new to this and i have no idea what that means can you explain please ?

TIA

Pesh

It means you still have errors in your brackets - how can I say it any simpler?

What is the line number that is the end of your setup() code - it is certainly not line 187. The compiler, however, thinks that your setup() code goes all the way to line 187 because there is something wrong with your brackets.

Go through your code line by line and every time you find an opening bracket check to see there is a matching closing bracket in the correct place. And when you find a closing bracket check that its opening bracket is in the right place.

Tedious, but simple, and essential.

...R

In the code you posted in reply #9, you almost certainly need a { on the line after If(millis()..... ( about the third line of loop( ) ).