Pressure sensor

Hello everyone,

So I have a pressure sensor hooked up to my arduino MEGA, and when I try to run the following code I get an error message that I dont understand:

int vOutMinus, vOutPlus, x, pressure_mbar, pressure_kPa;

analogReference(DEFAULT);
delay(20); // wait, there could be a capacitor at AVref.

vOutPlus = analogRead(0);
vOutMinus = analogRead(1);

// Calculation the pressure for 10% accuracy.
// Valid for -500 mbar to +600 mbar (-50kPa to +60kPa).

x = (vOutMinus-vOutPlus) + 5; // difference and offset.

// Curve fitting by trial and error for the SPX3058D
if (x > 0)
pressure_mbar = (x5) + (xx/13);
else
pressure_mbar = (x4) - (xx/24);

pressure_kPa = pressure_mbar / 10;

Serial.print (F("Pressure = "));
Serial.print(pressure_mbar,DEC);
Serial.println(F(" mbar"));

The error message says: 'vOutPlus' does not name a type
and if I delete the line that contains vOutPlus, I get: 'vOutMinus' does not name a type

can someone help me solve this problem?

I try to run the following code I get an error message that I dont understand:

Obviously, that error message means that you can't run the code. Running the code happens only after the code is compiled, linked, and uploaded.

You need to post ALL of your code, not just snippets. All executable code needs to be in functions.

To post code and/or error messages:

  1. Use CTRL-T in the Arduino IDE to autoformat your code.
  2. Paste the autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
  3. Paste the complete error message between code tags (the </> button)
    so that we can easily see and deal with your messages.

Before posting again, you should read the three locked topics at the top of the Programming Questions forum, and any links to which these posts point.

Good Luck!

Have a look in the learning section at the basics of Arduino coding. You can't just put a bunch of lines. Most of those lines need to be inside a function. You MUST have functions named setup and loop at least and most of the lines you've written belong in one or the other.