slipstick:
Please post the complete code.I can see at least 3 conditions even in that unhelpful fragment. Which one is "this condition"?
Steve
here is the full code
#define GREEN 3
#define BLUE 6
#define WHITE 10
#define RED 9
#define YELLOW 11
#define RED 5
const int ledPin = 3;
int ledState = LOW;
unsigned long previousMillis = 0;
const long interval = 1000;
byte statusLed = 13;
byte sensorInterrupt = 0;
byte sensorPin = 2;
float calibrationFactor = 4.5;
volatile byte pulseCount;
float flowRate;
unsigned int flowMilliLitres;
unsigned long totalMilliLitres;
unsigned long oldTime;
void setup()
{
Serial.begin(9600);
pinMode(statusLed, OUTPUT);
digitalWrite(statusLed, HIGH);
pinMode(sensorPin, INPUT);
digitalWrite(sensorPin, HIGH);
pinMode(GREEN,OUTPUT);
digitalWrite(GREEN,HIGH);
digitalWrite(GREEN,LOW);
pinMode(ledPin, OUTPUT);
pinMode(BLUE,OUTPUT);
digitalWrite(BLUE,HIGH);
digitalWrite(BLUE,LOW);
pinMode(WHITE,OUTPUT);
digitalWrite(WHITE,HIGH);
digitalWrite(WHITE,LOW);
pinMode(RED,OUTPUT);
digitalWrite(RED,HIGH);
digitalWrite(RED,LOW);
pinMode(YELLOW,OUTPUT);
digitalWrite(YELLOW,HIGH);
digitalWrite(YELLOW,LOW);
pulseCount = 0;
flowRate = 0.0;
flowMilliLitres = 0;
totalMilliLitres = 0;
oldTime = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
void loop()
{
if((millis() - oldTime) > 1000)
{
detachInterrupt(sensorInterrupt);
flowRate = ((1000.0 / (millis() - oldTime)) * pulseCount) / calibrationFactor;
oldTime = millis();
flowMilliLitres = (flowRate / 60) * 1000;
totalMilliLitres += flowMilliLitres;
if (ledState == LOW &&((flowRate < 0.01)) (digitalWrite(GREEN,HIGH));
{
ledState = HIGH;
}
else digitalWrite (GREEN,LOW);
if (flowRate >= 4.00) digitalWrite(BLUE,HIGH);
else digitalWrite (BLUE,LOW);
if (flowRate >= 12.01) digitalWrite(WHITE,HIGH);
else digitalWrite (WHITE,LOW);
if (flowRate >= 22.1) digitalWrite(RED,HIGH);
else digitalWrite (RED,LOW);
if (flowRate >= 34.1) digitalWrite(YELLOW,HIGH);
else digitalWrite (YELLOW,LOW);
unsigned int frac;
Serial.print("Flussometro: ");
Serial.print(int(flowRate));
Serial.print("L/min");
Serial.print("\t");
Serial.print("Quantita': ");
Serial.print(totalMilliLitres);
Serial.println("mL");
Serial.print("\t");
pulseCount = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
}
}
void pulseCounter()
{
pulseCount++;
}
the condition you can see in the void loop .
I just need to insert a double condition with double 'then' or 'do' to make a led blink when the flow is <0.01 (which will be a very good sign instead of just being lighted up ) , blinking is more notable
so my attempt was :
if (ledState == LOW &&((flowRate < 0.01)) (digitalWrite(GREEN,HIGH));
{
ledState = HIGH;
}
else digitalWrite (GREEN,LOW);
which did not work .. error in compiling /making order
Error message : expression cannot be used as a function, lighting up in red the '...If ..' string