SXRguyinMA
12-05-2010, 04:37 PM
Ok, I'm trying to make my Arduino display voltages for 12v, 5v and 3v lines. I've got a 16x2 LCD.
First, is it possible to get all 3 displayed at once? As in the top line being "3.3V 5V 12V" spaced evenly, then the bottom line being the 3 readings. I know they won't update all at the same time, but that's no big deal.
Second, if it's not possible, how do I need to set it up so when the unit is turned on it displays a welcome message, then with each button press it switches between 3v, 5v and 12v?
Here's my code so far for the second setup (with only 3v and 5v for now, still have to figure out how to read 12v without frying something):
/*Arduino Controlled Voltage Monitor
Code by Will Lyon 12/5/2010
Code for project Power House on TBCS
http://www.thebestcasescenario.com*/
#include <LiquidCrystal.h>
#include <math.h>
int counter = 0; //Add counter
int buttonPin = 2; //Attach button to pin 2
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() {
pinMode(buttonPin, INPUT); //Set button pin to input
lcd.begin(16, 2); //Set up the LCD's number of columns and rows
lcd.print(" POWER HOUSE");
lcd.setCursor(0, 1);
lcd.print("Desktop Pwr Unit");
}
void loop()
{
digitalRead(buttonPin); //Read the button pin
if (buttonPin = HIGH) //If the button is pressed
{
counter + 1; //Advance to next mode
if(counter == 2) //Reset count if over max mode number
{
counter = 1;
}
}
if(counter == 1)
{
lcd.print("3.3 Volt Line");
lcd.setCursor(0, 1);
lcd.print(analogRead(2));
}
else if(counter == 2)
{
lcd.print("5 Volt Line");
lcd.setCursor(0, 1);
lcd.print(analogRead(0));
}
}It displays the opening message, but when the button is pressed nothing happens.
Here is how it's wired up:
http://i92.photobucket.com/albums/l11/sportrider12584/Power%20House/powerhouse_bb.png
any ideas? Thanks!
First, is it possible to get all 3 displayed at once? As in the top line being "3.3V 5V 12V" spaced evenly, then the bottom line being the 3 readings. I know they won't update all at the same time, but that's no big deal.
Second, if it's not possible, how do I need to set it up so when the unit is turned on it displays a welcome message, then with each button press it switches between 3v, 5v and 12v?
Here's my code so far for the second setup (with only 3v and 5v for now, still have to figure out how to read 12v without frying something):
/*Arduino Controlled Voltage Monitor
Code by Will Lyon 12/5/2010
Code for project Power House on TBCS
http://www.thebestcasescenario.com*/
#include <LiquidCrystal.h>
#include <math.h>
int counter = 0; //Add counter
int buttonPin = 2; //Attach button to pin 2
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
void setup() {
pinMode(buttonPin, INPUT); //Set button pin to input
lcd.begin(16, 2); //Set up the LCD's number of columns and rows
lcd.print(" POWER HOUSE");
lcd.setCursor(0, 1);
lcd.print("Desktop Pwr Unit");
}
void loop()
{
digitalRead(buttonPin); //Read the button pin
if (buttonPin = HIGH) //If the button is pressed
{
counter + 1; //Advance to next mode
if(counter == 2) //Reset count if over max mode number
{
counter = 1;
}
}
if(counter == 1)
{
lcd.print("3.3 Volt Line");
lcd.setCursor(0, 1);
lcd.print(analogRead(2));
}
else if(counter == 2)
{
lcd.print("5 Volt Line");
lcd.setCursor(0, 1);
lcd.print(analogRead(0));
}
}It displays the opening message, but when the button is pressed nothing happens.
Here is how it's wired up:
http://i92.photobucket.com/albums/l11/sportrider12584/Power%20House/powerhouse_bb.png
any ideas? Thanks!