Цитата:
/*
* 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
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
*Pressure transducer Powered by 5v from Arduino
* Pressure transducer signal attached to analog input 0
* at 0 pressure my pressure transducer reads 0.25v
* at 2.5 BAR (36.26PSI) my pressure transducer reads 4.75v
*28.24 value below is 1024/28.24 as i thought this would convert the input to PSI?
*/
#include <LiquidCrystal.h> // include the LCD library
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);//Set the pin asignment for the LCD
int mappin = A0; //Pressure Transducer input pin
int mapValue1 = 0; //Input signal from pressure transducer
int mapValue2 = 0; // final display variable
void setup() {
lcd.begin(16, 2); // lcd rows and columns
lcd.print("Boost Pressure"); // title of sorts
}
void loop() {
mapValue1 = analogRead(mappin); // read the input (max 1024? is that correct?)
mapValue2 = mapValue1 / 28.24 ;// divide by 28.24 to get PSI Value
lcd.setCursor(0, 1);// set cursor to second row, first column
lcd.print(mapValue2);//display Value In PSI
lcd.print("PSI"); //print PSI at the end
delay(100); //wait 0.1 seconds
lcd.print(" ");//wipe the extra characters
delay(1);
}