Advertisement
safwan092

Untitled

Nov 29th, 2021
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LiquidCrystal_I2C.h>
  3.  
  4. const int pressureInput = A0;
  5. const int pressureZero = 102.4;
  6. const int pressureMax = 921.6;
  7. const int pressureTransducerMaxPSI = 100;
  8. const int baudRate = 9600;
  9. const int sensorReadDelay = 250;
  10.  
  11. int LED1 = 13;
  12. int LED2 = 12;
  13. float pressureValue = 0;
  14.  
  15. LiquidCrystal_I2C lcd(0x27, 20, 4);
  16.  
  17.  
  18. void setup()
  19. {
  20. Serial.begin(baudRate);
  21. lcd.init();
  22. lcd.init();
  23. lcd.backlight();
  24. }
  25.  
  26. void loop()
  27. {
  28. pressureValue = analogRead(pressureInput);
  29. pressureValue = ((pressureValue - pressureZero) * pressureTransducerMaxPSI) / (pressureMax - pressureZero);
  30. Serial.print(pressureValue, 1);
  31. Serial.println("PSI");
  32. lcd.setCursor(0, 0);
  33. lcd.print("Pressure:");
  34. lcd.print(pressureValue, 1);
  35. lcd.print("psi");
  36. lcd.print("psi");
  37. delay(sensorReadDelay);
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement