This is my code after editing, i have change the int to void for the rpm
void rpm() //integer function that can store between -32768 and 32767.
this is my full code
#include <Servo.h>
Servo myservo;
volatile int NbTopsFan; //measuring the rising edges of the signal
int Calc;
int potPin = 0; //analog pin ued to connect the sensor
int ledPin = 9; //select pin for the servo
int val = 0; //variable to read the value from the analog pin
void rpm() //integer function that can store between -32768 and 32767.
{
NbTopsFan++; //This function measures the rising and falling edge of the
}
{
myservo.attach(9); //set up the servo as usual
pinMode(ledPin, OUTPUT); //variable to store the value coming from the sensor
pinMode(potPin, INPUT); //initializes digital pin 0 as an input
Serial.begin(9600); //for watching the speeds in the serial monitor
attachInterrupt(0, rpm, RISING); //and the interrupt is attached
}
void loop()
{
NbTopsFan = 0; //Set NbTops to 0 ready for calculations
sei(); //Enables interrupts
val = analogRead(potPin); // read the value from the sensor
val = map(val,0,1023,0,179);
cli(); //Disable interrupts
Calc = (NbTopsFan * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
if (val>79) myservo.writeMicroseconds(0); //set servo to mid-point
else if (val<80) myservo.writeMicroseconds(1500);
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line
Serial.println(val);
delay(10);
}
BUT I still got this error message at this line,
{
NbTopsFan++; //This function measures the rising and falling edge of the
}
{
it says
sketch_may03a:14: error: expected unqualified-id before '{' token
hmm...how do i fix this error?