New user- Remove leading zero & add max PSI

Hello Everyone! noobie here and im stuck in a little rut.

Im displaying a pressure transducer voltage and PSI to a 1602 LCD.

I want to change two things:

  1. remove the leading zero on the voltage display; turn V:0.49 into V:.49 on the LCD
  2. add a max PSI reading

ideas?

Code:

/*
LiquidCrystal Library - Hello World

Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.

This sketch prints "Hello World!" to the LCD
and shows the time.

The circuit:

  • LCD RS pin to digital pin 12
  • LCD Enable pin to digital pin 11
  • LCD D4 pin to digital pin 5
  • LCD D5 pin to digital pin 4
  • LCD D6 pin to digital pin 3
  • LCD D7 pin to digital pin 2
  • LCD R/W pin to ground
  • LCD VSS pin to ground
  • LCD VCC pin to 5V
  • 10K resistor:
  • ends to +5V and ground
  • wiper to LCD VO pin (pin 3)

Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi

This example code is in the public domain.

*/

// include the library code:
#include <LiquidCrystal.h>

// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

int analogpin = A0;
int val;

void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
Serial.begin(9600);
// send an intro:
Serial.println("\n\nString length() and trim():");
Serial.println();
}
void loop() {

int sensorVal=analogRead(A0);
Serial.println(sensorVal);
float voltage = (sensorVal*5.0)/1024.0;
Serial.print("Volts:"); //voltage displayed in serial data - used for calibration work if not on LCD
Serial.print(voltage); //voltage displayed in serial data - used for calibration work if not on LCD
float pressure_psi = ((voltage - 0.49) / .0267) +.0654; //.0654 calibrates the psi reading from -.06 to 0.00
lcd.setCursor(9,1); //position - 0-16 left to right; row 0 is top, 1 bottom,
lcd.print("PSI:"); //text display
Serial.print(pressure_psi, 1.0); //voltage transfer displayed in serial data - used for calibration work if not on LCD
lcd.print(pressure_psi, 1.0); //this is the displayed pressure calculation; ,1.0 defines decimal place - use float for .000 and int for whole #
lcd.setCursor(10,0);
lcd.print("V:");
lcd.print(voltage);
lcd.setCursor(0, 0);
lcd.print("Coolant");
delay (100);
// print the number of seconds since reset for checking that lcd is updated:
lcd.setCursor(0, 1);
lcd.print(millis() / 1000);
lcd.print("S");
}

  1. remove the leading zero on the voltage display; turn V:0.49 into V:.49 on the LCD

Try this

  Serial.print(".");
  Serial.println((int)(voltage * 100));
  1. add a max PSI reading

Declare a new variable to hold the max PSI and set it to zero
When you have a new PSI value compare it with the max value and if it is higher set the max value to the current PSI value and print it on the LCD

  1. remove the leading zero on the voltage display; turn V:0.49 into V:.49 on the LCD

If you were writing the program for me, and you did that, I'd kick your ass all over the place.

Thank you for the input. I will give it a shot and report back.

What's wrong with having the layout of the voltage like that? There's a lot that I need to learn, maybe that is part of it.

What's wrong with having the layout of the voltage like that?

It makes it difficult to read for one thing

Serial.print(".");
Serial.println((int)(voltage * 100));

  • did not work, maybe its just me, idk. i did figure out using white space, so that works too, but a bit untidy.
    i decided to take the voltage off the screen for now.

Ideas on making a rotating screen; one screen holds for say 10 seconds, then fades out to "another" screen that displays different data, holds for 10 seconds, then goes back to the first screen?

Serial.print(".");
Serial.println((int)(voltage * 100));

  • did not work, maybe its just me, idk.

I assume that you printed ot to the LCD rather than the Serial monitor