Count fuel liters with Arduino We have created a fuel sensor in our lab with Arduino in order to get fuel data from vehicles. Regarding the code below, I receive an error


  PARSE ERROR: 'attachInterrupt': this function needs to be defined.


Could you please advice?

int pin = 2;
volatile unsigned int pulse;
float volume = 0;
float flow_rate =0;
const int pulses_per_litre = 2000;
int count_pulse;

void setup()
{
    Serial.begin(9600);
    pinMode(pin, INPUT);
    attachInterrupt(0, count_pulse, RISING);

}

void loop()
{
    pulse=0;
    interrupts();
    delay(1000); 
    noInterrupts();

    Serial.print("Pulses per second: ");
    Serial.println(pulse);

    flow_rate = pulse * 1000/pulses_per_litre; //

    Serial.print("FUEL FLOW rate: ");
    Serial.print(flow_rate);
    Serial.println(" milliliters per second");

    volume = volume + flow_rate * 0.1; //Time Interval is 0.1 second

    Serial.print("Volume: ");
    Serial.print(volume);
    Serial.println(" milliliters");
}

void count_pulse()
{
pulse++;}
You have declared count_pulse as a variable and NOT as function prototype.

int pin = 2;
volatile unsigned int pulse;
float volume = 0;
float flow_rate =0;
const int pulses_per_litre = 2000;

void count_pulse(); \\ &lt;--- Function prototype

void setup()
{
    Serial.begin(9600);
    pinMode(pin, INPUT);
    attachInterrupt(0, count_pulse, RISING);
}