hi everyone ,
i have been assigned a pressure altitude sensor arduino project as part of end of year college exams.
i am only a beginner at coding and am finding this assignment really tough.the project spec is below followed by my coding any help would be greatly appreciated as to where i am going so badly wrong.thanks so much
benny
im really bdaly stuck,
“Pressure/Altitude sensor”
Sense pressure and convert to altitude with an input to compensate for prevailing barometric pressure. The system should report its readings to the serial port. The pressure sensor employed will be an MPX4115A
void setup() {
Serial.begin(9600);
}
void loop(){
float pressure = readPressure(A1);
float millibars = pressure/100;
int const altitude = 2; // verify if it is right
Serial.println();
Serial.print("Pressure = ");
Serial.print(pressure);
Serial.println(" pascals");
Serial.print("Pressure = ");
Serial.print(millibars);
Serial.println(" millibars");
delay(1000);
}
/* Reads pressure from the given pin.
- Returns a value in Pascals
*/
float readPressure(int pin){
int pressureValue = analogRead(pin);
float pressure=((pressureValue/1024.0)+0.095)/0.000009;
return pressure;
}
// changing from pressure to altitude
float readaltitude(int pin){
float altitude =((-14.76 * pressure value)+14952); // change 200 to the statement
return altitude;
Serial.println();
Serial.print("altitude = ");
Serial.print(altitude);
Serial.println(" meters");
Serial.print("meters = ");
Serial.println(" meters");
delay(1000);
}