OP's code (.ino) :
#include "DEV_Config.h"
#include "LCD_Driver.h"
#include "LCD_GUI.h"
void setup()
{
System_Init();
Serial.begin(9600);
Serial.println("4inch TFT Touch Shiled LCD Show...");
Serial.println("LCD Init...");
LCD_SCAN_DIR Lcd_ScanDir = SCAN_DIR_DFT;
LCD_Init( Lcd_ScanDir, 100);
char closed_stat='CLOSED';
Serial.println("LCD_Clear...");
LCD_Clear(LCD_BACKGROUND);
Serial.println("LCD_Show...");
GUI_Show();
}
void loop()
{
int sensorVal=analogRead(A1);
float voltage = (sensorVal*5.0)/1024.0;
float pressure_bar = ((3.0*((float)voltage-0.45))*1000000.0)/10e5;
if(pressure_bar<0)
{
GUI_DisString_EN(300, 80, "-", &Font20, LCD_BACKGROUND, BLACK);
}
else
{
GUI_DisString_EN(300, 80, "+", &Font20, LCD_BACKGROUND, BLACK);
}
Serial.println (pressure_bar);
GUI_DisString_EN(315, 80, " ", &Font20, LCD_BACKGROUND, BLACK);
GUI_DisNum(315, 80, pressure_bar, &Font20, LCD_BACKGROUND, BLACK);
GUI_DisString_EN(345, 80, ".", &Font20, LCD_BACKGROUND, BLACK);
GUI_DisString_EN(360, 100, "CLOSED", &Font20, LCD_BACKGROUND, BLACK);
GUI_DisString_EN(360, 120, "CLOSED", &Font20, LCD_BACKGROUND, BLACK);
}
/*********************************************************************************************************
END FILE
*********************************************************************************************************/
Can you give a link to the pressure sensor and state how you are applying pressure to test it ?
This formula implies some significant pressures, if the device outputs anything like up to 5 volts:
float pressure_bar = ((3.0*((float)voltage-0.45))*1000000.0)/10e5;
what happens if you try this ?
float pressure_bar = 3.0*((float)voltage-0.45) ; // 10e5 = 10 * 10^5 = 1,000,000
If you are simply testing the ability of your program to display a float, simply hard code the pressure at a reasonable value say 2.3456 ) to see what happens. By default, Serial.print displays floats to 2 decimal places.