I am frustrated that I can't read/display a dc voltage on Analog Pin 0.
Any idea where am going wrong? The LCD displays text as expected - just cant seem to display voltage.
#include <WString.h>
#include <Wire.h>
int inputVoltagePin = 0; //int batt volts = input pin 0;
int lcd = 40;
void lcd2s_init()
{
delay(300);
Wire.beginTransmission (lcd); // transmit to device 0x50
Wire.send (0x8C); // send lcd clear command
Wire.endTransmission (); // stop transmitting
delay(500);
Wire.beginTransmission (lcd); // transmit to device 0x50
Wire.send (0x28); // turn B/light ON
Wire.endTransmission (); // stop transmitting
delay(300);
}
void setup ()
{
Wire.begin();
lcd2s_init();
Wire.beginTransmission(lcd); // transmit to device 0x50
Wire.send (0x80); // ready to move cursor to location given by next byte
Wire.send ("Battery Volts =\n");//dispaly volts on next line
Wire.endTransmission(); // stop transmitting
}
void loop ()
{
delay(300);
// read voltage value
int voltage = analogRead(inputVoltagePin);
int valueVolts=voltage;
Wire.beginTransmission(lcd); // transmit to device 0x50
Wire.send (valueVolts);
Wire.endTransmission(); // stop transmitting
delay (6000);
Wire.beginTransmission(lcd); // transmit to device 0x50
Wire.send (0x20);//backlight off
Wire.endTransmission(); // stop transmitting
}