Problem in Coding for pressure Sensor

Hi! Can you please help me with my code?

#include <SFE_BMP180.h>

#include <FastLED.h>

#include <Wire.h>
#include <SFE_BMP180.h>

SFE_BMP180 BMP180;

const int buzzer = 9; //buzzer to arduino pin 9

const int ledPin = 13;
const int ldrPin = A0;


#define LED_PIN 7
#define NUM_LEDS 20

CRGB leds[NUM_LEDS];

void setup() {
  Serial.begin(9600);
  bool success = BMP180.begin();

  if (success) {
    Serial.println("BMP180 init success");
  }
{ pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
  
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(ldrPin, INPUT);
    
    // put your setup code here, to run once:
  pinMode(10,OUTPUT);
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
}
}
void loop() {
{
  
{
  tone(buzzer, 1000); // Send 1KHz sound signal...
  delay(1000);        // ...for 5 sec
  noTone(buzzer);     // Stop sound...
  delay(30000);        // ...for 30 sec
}
  int ldrStatus = analogRead(ldrPin);

  if (ldrStatus <= 400)
  {
    digitalWrite(ledPin, HIGH);
    Serial.print("Its Dark, Turn on the LED:");
    Serial.println(ldrStatus);
  }
  else
  {
    digitalWrite(ledPin, LOW);
    Serial.print("Its Bright, Turn off the LED:");
    Serial.println(ldrStatus);
  }
  
  
  // put your main code here, to run repeatedly:
  digitalWrite(10,HIGH);
  delay(1000);
  digitalWrite(10,LOW);
  
  char status;
  double T, P;
  bool success = false;

  status =  BMP180.startTemperature();
  int PressureValve;
  
  if (status != 0) {
    delay(1000);
    status = BMP180.getTemperature(T);

    if (status != 0) {
      status = BMP180.startPressure(3);

      if (status != 0) {
        delay(status);
        status = BMP180.getPressure(P,T);

        if (status != 0) {
          Serial.print("Pressure: ");
          Serial.print(P);
          Serial.println(" hPa");

          Serial.print("Temperature: ");
          Serial.print(T);
          Serial.println(" C");

        (PressureValve =("Pressure: ")  
          
if (PressureValve = < 1007.00 hPa) 
{
    "led[0] = CRGB(255, 0, 0)";
    FastLED.show();
    delay(0);   // do stuff if the condition is false
    Serial.println("OFF LED");
 }
  
   else ("Pressure > = 1010.00 hPa" )
 { 
  digitalWrite(10,HIGH);
  delay(5000);
  digitalWrite(10,LOW); // do stuff if the condition is true
  Serial.println("ON LED");
 }       
 
        }
      }
    }
  }
}    

 
}

Here are my errors :

 (PressureValve =("Pressure: ")  

                        ^

Testing:98: error: expected ')' before 'if'

 if () (PressureValve = < 1007.00 hPa) 

 ^

Testing:106: error: expected ';' before 'else'

    else ("Pressure > = 1010.00 hPa" )

    ^

exit status 1
expected ')' before 'if'
(PressureValve = ("Pressure: ")

Missing semicolon at the end and what is that opening bracket there for at the start ?

Hi,

the code line

if () (PressureValve = < 1007.00 hPa)

is not part of the code you have posted.
So you must have posted a different code than the one that caused the compiler-error

best regards Stefan

As an additional comment. This is your first post.
As a very first program the code you have posted is pretty "sophisticated"
What is the history behind the code you have posted?
Please describe in detail how this code was written.
best regards Stefan

This coding was written for a project to detect pressure on it and to light up led strip after it detected.
Having some error coming to the near to the end of this project. Before that we alright but we needed the pressure have a certain amount then the led strip light up, thats when the problem occur.
The coding was taken online and added in with some other written in.

This code line was added in by myself

if (PressureValve = < 1007.00 hPa)

As to let the pressure below that , not to light up the led strip as explain in my above reply.

Please clarify exactly which sketch you were compiling when you get the error. Was it the code that you originally posted or a different sketch ? If it was a different sketch then please post it here in a new post rather than modifying your original post so that the comments about it still make sense

This Current sketch that i posted when i got the errors.

PressureValue is declared as an int, ie a number

So when you do

(PressureValve =("Pressure: ")

What are you trying to do ?

I wanted the pressure valve ie number to on/off the led.

Could tell me whether it is possible to on/ off using my current coding? Or could you help to add some coding to make it work?

Thanks so much :wink:

Please describe in English what you want the sketch to do

if (PressureValve = < 1007.00 hPa) PressureValve is an integer value, isn’t it?
It knows nothing about values after the decimal point, or units.

UKHeliBob:
Please describe in English what you want the sketch to do

I need the sketch to do (Board : Arduino Uno)

1 - When the project is started the buzzer will ring
2 - detect a certain amount of pressure when something on the pressure sensor
3 - after it reach a amount it will light up led
4 - like wise if nothing on the pressure sensor the led would not light up.
5 - The Buzzer will ring again and the project ends.

My codes

#include <SFE_BMP180.h>

#include <SFE_BMP180.h>

#include <FastLED.h>

#include <Wire.h>
#include <SFE_BMP180.h>

SFE_BMP180 BMP180;

const int buzzer = 9; //buzzer to arduino pin 9

const int ledPin = 13;
const int ldrPin = A0;


#define LED_PIN 7
#define NUM_LEDS 20

CRGB leds[NUM_LEDS];

void setup() {
  Serial.begin(9600);
  bool success = BMP180.begin();

  if (success) {
    Serial.println("BMP180 init success");
  }
{ pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
  
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  pinMode(ldrPin, INPUT);
    
    // put your setup code here, to run once:
  pinMode(10,OUTPUT);
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
}
}
void loop() {
{
  
{
  tone(buzzer, 1000); // Send 1KHz sound signal...
  delay(1000);        // ...for 5 sec
  noTone(buzzer);     // Stop sound...
  delay(30000);        // ...for 30 sec
}
  int ldrStatus = analogRead(ldrPin);

  if (ldrStatus <= 400)
  {
    digitalWrite(ledPin, HIGH);
    Serial.print("Its Dark, Turn on the LED:");
    Serial.println(ldrStatus);
  }
  else
  {
    digitalWrite(ledPin, LOW);
    Serial.print("Its Bright, Turn off the LED:");
    Serial.println(ldrStatus);
  }
  
  
  // put your main code here, to run repeatedly:
  digitalWrite(10,HIGH);
  delay(1000);
  digitalWrite(10,LOW);
  
  char status;
  double T, P;
  bool success = false;

  status =  BMP180.startTemperature();
  int PressureValve;
  
  if (status != 0) {
    delay(1000);
    status = BMP180.getTemperature(T);

    if (status != 0) {
      status = BMP180.startPressure(3);

      if (status != 0) {
        delay(status);
        status = BMP180.getPressure(P,T);

        if (status != 0) {
          Serial.print("Pressure: ");
          Serial.print(P);
          Serial.println(" hPa");

          Serial.print("Temperature: ");
          Serial.print(T);
          Serial.println(" C");
 
 PressureValve =("Pressure:") 
          
if ("PressureValve = < 1007 hPa") 
{
    "led[0] = CRGB(255, 0, 0)";
    FastLED.show();
    delay(0);   // do stuff if the condition is false
    Serial.println("OFF LED");
 }
  
   else ("PressureValve >= 1010 hPa");
 { 
  digitalWrite(10,HIGH);
  delay(5000);
  digitalWrite(10,LOW); // do stuff if the condition is true
  Serial.println("ON LED");
 }       
 
        }
      }
    }
  }
}    

 
}

My errors

Arduino\sketch_nov16a\sketch_nov16a.ino:98:16: warning: invalid conversion from 'const char*' to 'int' [-fpermissive]

  PressureValve =("Pressure:")

                ^

sketch_nov16a:100: error: expected ';' before 'if'

 if ("PressureValve = < 1007 hPa") 

 ^

sketch_nov16a:108: error: expected '}' before 'else'

    else ("PressureValve >= 1010 hPa");

    ^

C:\Users\NPStudent\Desktop\Arduino\sketch_nov16a\sketch_nov16a.ino: At global scope:

sketch_nov16a:123: error: expected declaration before '}' token

 }

 ^

exit status 1
expected ';' before 'if'

The error message tells you all! :o

  PressureValve =("Pressure:")

                ^

sketch_nov16a:100: error: expected ';' before 'if'

All you had to do i put the missing semi-colon on line 93 of your code and it would compile with no errors!

(compiles, NOT tested!)

#include <FastLED.h>
#include <Wire.h>
#include <SFE_BMP180.h>

SFE_BMP180 BMP180;

const int buzzer = 9; //buzzer to arduino pin 9

const int ledPin = 13;
const int ldrPin = A0;


#define LED_PIN 7
#define NUM_LEDS 20

CRGB leds[NUM_LEDS];

void setup() {
  Serial.begin(9600);
  bool success = BMP180.begin();

  if (success) {
    Serial.println("BMP180 init success");
  }
  { pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output

    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
    pinMode(ldrPin, INPUT);

    // put your setup code here, to run once:
    pinMode(10, OUTPUT);
    FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
  }
}
void loop() {
  {

    {
      tone(buzzer, 1000); // Send 1KHz sound signal...
      delay(1000);        // ...for 5 sec
      noTone(buzzer);     // Stop sound...
      delay(30000);        // ...for 30 sec
    }
    int ldrStatus = analogRead(ldrPin);

    if (ldrStatus <= 400)
    {
      digitalWrite(ledPin, HIGH);
      Serial.print("Its Dark, Turn on the LED:");
      Serial.println(ldrStatus);
    }
    else
    {
      digitalWrite(ledPin, LOW);
      Serial.print("Its Bright, Turn off the LED:");
      Serial.println(ldrStatus);
    }


    // put your main code here, to run repeatedly:
    digitalWrite(10, HIGH);
    delay(1000);
    digitalWrite(10, LOW);

    char status;
    double T, P;
    bool success = false;

    status =  BMP180.startTemperature();
    int PressureValve;

    if (status != 0) {
      delay(1000);
      status = BMP180.getTemperature(T);

      if (status != 0) {
        status = BMP180.startPressure(3);

        if (status != 0) {
          delay(status);
          status = BMP180.getPressure(P, T);

          if (status != 0) {
            Serial.print("Pressure: ");
            Serial.print(P);
            Serial.println(" hPa");

            Serial.print("Temperature: ");
            Serial.print(T);
            Serial.println(" C");

            PressureValve = ("Pressure:");

            if ("PressureValve = < 1007 hPa")
            {
              "led[0] = CRGB(255, 0, 0)";
              FastLED.show();
              delay(0);   // do stuff if the condition is false
              Serial.println("OFF LED");
            }

            else ("PressureValve >= 1010 hPa");
            {
              digitalWrite(10, HIGH);
              delay(5000);
              digitalWrite(10, LOW); // do stuff if the condition is true
              Serial.println("ON LED");
            }

          }
        }
      }
    }
  }


}

hope that helps…

sherzaad:
The error message tells you all! :o

  PressureValve =("Pressure:")

^

sketch_nov16a:100: error: expected ‘;’ before ‘if’




All you had to do i put the missing semi-colon on line 93 of your code and it would compile with no errors!

(compiles, NOT tested!)


#include <FastLED.h>
#include <Wire.h>
#include <SFE_BMP180.h>

SFE_BMP180 BMP180;

const int buzzer = 9; //buzzer to arduino pin 9

const int ledPin = 13;
const int ldrPin = A0;

#define LED_PIN 7
#define NUM_LEDS 20

CRGB leds[NUM_LEDS];

void setup() {
 Serial.begin(9600);
 bool success = BMP180.begin();

if (success) {
   Serial.println(“BMP180 init success”);
 }
 { pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output

Serial.begin(9600);
   pinMode(ledPin, OUTPUT);
   pinMode(ldrPin, INPUT);

// put your setup code here, to run once:
   pinMode(10, OUTPUT);
   FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
 }
}
void loop() {
 {

{
     tone(buzzer, 1000); // Send 1KHz sound signal…
     delay(1000);        // …for 5 sec
     noTone(buzzer);     // Stop sound…
     delay(30000);        // …for 30 sec
   }
   int ldrStatus = analogRead(ldrPin);

if (ldrStatus <= 400)
   {
     digitalWrite(ledPin, HIGH);
     Serial.print(“Its Dark, Turn on the LED:”);
     Serial.println(ldrStatus);
   }
   else
   {
     digitalWrite(ledPin, LOW);
     Serial.print(“Its Bright, Turn off the LED:”);
     Serial.println(ldrStatus);
   }

// put your main code here, to run repeatedly:
   digitalWrite(10, HIGH);
   delay(1000);
   digitalWrite(10, LOW);

char status;
   double T, P;
   bool success = false;

status =  BMP180.startTemperature();
   int PressureValve;

if (status != 0) {
     delay(1000);
     status = BMP180.getTemperature(T);

if (status != 0) {
       status = BMP180.startPressure(3);

if (status != 0) {
         delay(status);
         status = BMP180.getPressure(P, T);

if (status != 0) {
           Serial.print(“Pressure: “);
           Serial.print(P);
           Serial.println(” hPa”);

Serial.print(“Temperature: “);
           Serial.print(T);
           Serial.println(” C”);

PressureValve = (“Pressure:”);

if (“PressureValve = < 1007 hPa”)
           {
             “led[0] = CRGB(255, 0, 0)”;
             FastLED.show();
             delay(0);   // do stuff if the condition is false
             Serial.println(“OFF LED”);
           }

else (“PressureValve >= 1010 hPa”);
           {
             digitalWrite(10, HIGH);
             delay(5000);
             digitalWrite(10, LOW); // do stuff if the condition is true
             Serial.println(“ON LED”);
           }

}
       }
     }
   }
 }

}




hope that helps...

I did that but it come out this.

case 2: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

                                                       ^

exit status 1
Error compiling for board Arduino/Genuino Uno.

I did that but it come out this.

Is that the full error message ?

UKHeliBob:
Is that the full error message ?

Sorry i did not the full error message. Was too urgent to copy the error message.

The Full error message :

In file included from E:\UV_Project_Coding\Testing\Testing.ino:4:0:

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/FastLED.h:14:21: note: #pragma message: FastLED version 3.003.003

 #    pragma message "FastLED version 3.003.003"

                     ^

In file included from C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/fastled_avr.h:6:0,

                 from C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms.h:39,

                 from C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/FastLED.h:52,

                 from E:\UV_Project_Coding\Testing\Testing.ino:4:

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h: In static member function 'static void ClocklessController<DATA_PIN, T1, T2, T3, RGB_ORDER, XTRA0, FLIP, WAIT_TIME>::showRGBInternal(PixelController<RGB_ORDER>&)':

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:326:24: error: expected primary-expression before '__attribute__'

 #define FL_FALLTHROUGH __attribute__ ((fallthrough));

                        ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:409:55: note: in expansion of macro 'FL_FALLTHROUGH'

      case 4: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

                                                       ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:326:24: error: expected primary-expression before '__attribute__'

 #define FL_FALLTHROUGH __attribute__ ((fallthrough));

                        ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:410:55: note: in expansion of macro 'FL_FALLTHROUGH'

      case 3: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

                                                       ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:326:24: error: expected primary-expression before '__attribute__'

 #define FL_FALLTHROUGH __attribute__ ((fallthrough));

                        ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:411:55: note: in expansion of macro 'FL_FALLTHROUGH'

      case 2: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

                                                       ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:326:24: error: expected primary-expression before '__attribute__'

 #define FL_FALLTHROUGH __attribute__ ((fallthrough));

                        ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:425:55: note: in expansion of macro 'FL_FALLTHROUGH'

      case 4: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

                                                       ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:326:24: error: expected primary-expression before '__attribute__'

 #define FL_FALLTHROUGH __attribute__ ((fallthrough));

                        ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:426:55: note: in expansion of macro 'FL_FALLTHROUGH'

      case 3: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

                                                       ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:326:24: error: expected primary-expression before '__attribute__'

 #define FL_FALLTHROUGH __attribute__ ((fallthrough));

                        ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:427:55: note: in expansion of macro 'FL_FALLTHROUGH'

      case 2: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

                                                       ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:326:24: error: expected primary-expression before '__attribute__'

 #define FL_FALLTHROUGH __attribute__ ((fallthrough));

                        ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:444:55: note: in expansion of macro 'FL_FALLTHROUGH'

      case 4: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

                                                       ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:326:24: error: expected primary-expression before '__attribute__'

 #define FL_FALLTHROUGH __attribute__ ((fallthrough));

                        ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:445:55: note: in expansion of macro 'FL_FALLTHROUGH'

      case 3: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

                                                       ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:326:24: error: expected primary-expression before '__attribute__'

 #define FL_FALLTHROUGH __attribute__ ((fallthrough));

                        ^

C:\Users\NPStudent\Documents\Arduino\libraries\FastLED/platforms/avr/clockless_trinket.h:446:55: note: in expansion of macro 'FL_FALLTHROUGH'

      case 2: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

                                                       ^

E:\UV_Project_Coding\Testing\Testing.ino: In function 'void loop()':

E:\UV_Project_Coding\Testing\Testing.ino:96:27: warning: invalid conversion from 'const char*' to 'int' [-fpermissive]

             PressureValve = ("Pressure:");

                           ^

exit status 1
Error compiling for board Arduino/Genuino Uno.

bryan021:
I did that but it come out this.

case 2: _D2(0) LO1 _D3(0) HI1 _D1(1) QLO2(b0,0)  FL_FALLTHROUGH

^

exit status 1
Error compiling for board Arduino/Genuino Uno.

as previously mentioned I was able to compile your code with no errors.
for FastLED I used this library and
for SFE_BMP180 this one.

my IDE is 1.8.12.

if I may suggest, remove any libraries relating to SFE_BMP180 or FastLED download these and try compiling your code again.

hope that helps

sherzaad:
as previously mentioned I was able to compile your code with no errors.
for FastLED I used this library and
for SFE_BMP180 this one.

my IDE is 1.8.12.

if I may suggest, remove any libraries relating to SFE_BMP180 or FastLED download these and try compiling your code again.

hope that helps

May i ask which version of SFE_BMP180 and FastLED?

As there are many version of SFE_BMP180 in the link you posted same for FastLED.