- Mon Mar 17, 2014 2:29 pm
#169487
If you're still lost and have really given it a try, here's something close to the final answer. I say close as I don't know what you have for an external voltage divider for each voltage, and thus don't know what to use for the ADC gain. I could guess from the comments but I've got to leave something for you to do.
Code: Select all
I forsee one problem with the way you've got the display written (I copied your code). Think about what might happen if you send 48.125 to the LCD followed by 47.8 in the next loop for the same voltage display. What will show up on the LCD ?#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <LiquidCrystal.h>
Adafruit_ADS1015 ads1015;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup(void)
{
Serial.begin(9600);
lcd.begin(16, 2);
Serial.println("Hello!");
Serial.println("ADC Range: +/- 6.144V (1 bit = 3mV)");
ads1015.begin();
}
void loop(void)
{
int chgaReading = ads1015.readADC_SingleEnded(0);
float chgaVolts = chgaReading * 1.0 / 27.0 ;
lcd.setCursor(0, 0);
lcd.print ("+ A");
lcd.setCursor (1, 0);
lcd.print(chgaVolts);
int bavoltReading = ads1015.readADC_SingleEnded(2);
float bavoltVolts = bavoltReading * 1.0 / 56.0 ;
lcd.setCursor (9, 0);
lcd.print (" V");
lcd.setCursor (10, 0);
lcd.print (bavoltVolts);
delay(1000);
}