Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int sensorPin = A0;
- int sensorValue = 0;
- float Vout=0;
- float P=0;
- void setup() {
- // declare the ledPin as an OUTPUT:
- Serial.begin(9600);
- }
- void loop() {
- int i=0;
- int sum=0;
- int offset=0;
- Serial.println("init...");
- for(i=0;i<10;i++)
- {
- sensorValue = analogRead(sensorPin)-512;
- sum+=sensorValue;
- }
- offset=sum/10.0;
- Serial.println("Ok");
- while(1)
- {
- sensorValue = analogRead(sensorPin)-offset;
- Vout=(5*sensorValue)/1024.0;
- P=(Vout-2.5)*1000; // Pascal
- Serial.print("dP=" );
- Serial.print(P*1000);
- Serial.print("[Pa]");
- Serial.print(" V=" );
- Serial.print(sqrt(abs(2*9.81*P/12.26)));
- Serial.println("[m/sec]");
- delay(1000);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement