Monday, May 15, 2023

Pressure Gauge Digital Range 1450 PSIG

/*
// definisi variabel
float bacapressure;
float pressure;
float rumus; 
float konstan = 0.13158; 
float maxi = 935;
float zero = 175; //(kalo kekecilan hasil psi-nya, ini naikkan) paling 168
float range = 100;

rumus = ((bacapressure-zero)*(range/(maxi-zero)));

*/
//-----------------------------------------------------------
/*
//14 Mei 2023
Code by: Gede A Setiawan
gedeasetiawan@yahoo.com
KETERANGAN
LCD:
SCL: D1
SDA: D2
VCC: 5V (kalo 3v gak bisa hidup lcd nya)
GND: GND

PRESSURE SENSOR:
Red: 5v --> output byte 175 (ubah 175 di konstanta zero)
Red: 3v --> output byte 120 (ubah 120 di konstanta zero)
Black: Gnd: Ground
Yellow: data --> A0

offset: 9.48 - 11.37 = 1.89 atau setara 0.13%
*/
//-----------------------------------------------------------
float inputpressure = A0;

//lcd
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);

// defenisi variabel
float bacapressure;
float rumus; 
float konstan = 0.13158; //??
float maxi = 935; //output byte saat dikasi pressure pada range maximal 
float zero = 176; //(kalo kekecilan hasil psi-nya, ini naikkan) paling 168
float range = 1450; //range maximal sensor 


void setup() {
  lcd.begin(); //lcd inisiasi
  pinMode(inputpressure, INPUT);
  Serial.begin(9600);
  delay(10);
}
void loop() {
bacapressure = analogRead(inputpressure);
//rumus = (bacapressure*5/1024); 
//rumus = (((bacapressure)*5/1024)-4.23); 
//rumus = ((((bacapressure)/1024*5))-4.7)*1450; 
rumus = ((bacapressure-zero)*(range/(maxi-zero)));

if (rumus < 0) rumus = 0;

Serial.print("Data asli: ");
Serial.print(bacapressure);
Serial.print(" Pressure: ");
Serial.println(rumus);
Serial.println("-------------");
delay(200);

  lcd.setCursor(0,0);
  lcd.print("Pressure Gauge");
  lcd.setCursor(0,1);
  lcd.print(rumus);
  lcd.print(" psig ");
  delay(200);
}

No comments: