Demo entry 6353173

air pressure sensor

   

Submitted by anonymous on Mar 31, 2017 at 01:38
Language: C. Code size: 501 Bytes.

void setup() {
 Serial.begin(9600);
}
 
void loop()
{
 //Reads pressure from the given pin.
 float pressure = readPressure(A0); 
 Serial.println();
 Serial.print("Pressure = ");
 Serial.print(pressure);
 Serial.print(" kPa = ");
 Serial.print(pressure/100);
 Serial.println(" bar ");
 delay(1000);
}
 
//Returns a value in Pascals

float readPressure(int pin)
{
 int pressureValue = analogRead(pin);
 float pressure=((pressureValue/1024.0)-0.04)/0.000901;
 return pressure;
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).