I have decided to use the i2c RGB shield for a couple of reasons. 1. It can be hooked up with just four pins. 2. It has five buttons, left, right, up, down, and select for a menu controll mechanism and setting variables. The shield can be bought as a kit and takes many 16x2 lcd's both monochrome and color back light. Her is the code for the shield I will be using, along with the temperature and humidity sensor.
------------------------------
/*********************
i2c RGB LCD Shield with 5 buttons and display
**********************/
// include the library code:
#include <Wire.h>
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>
// The shield uses the I2C SCL and SDA pins. On classic Arduinos
// this is Analog 4 and 5 so you can't use those for analogRead() anymore
// However, you can connect other I2C sensors to the I2C bus and share
// the I2C bus.
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
// These #defines make it easy to set the backlight color
#define RED 0x1
#define YELLOW 0x3
#define GREEN 0x2
#define TEAL 0x6
#define BLUE 0x4
#define VIOLET 0x5
#define WHITE 0x7
// setup variables
int LCD_C=16;
int LCD_R=2;
int time=0;
uint8_t i=0;
// setup
void setup() {
// Debugging output
SPrintBegin();
// set up the LCD's number of columns and rows:
PrintBegin();
PrintMessage();
// Print a message to the LCD. We track how long it takes since
// this library has been optimized a bit and we're proud of it
lcd.print("Hello, world!");
GetTime();
}// end setup
// loop
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
ReadButtons();
} // end loop
// -- Functions---//
// print setup routine
void PrintBegin()
{
lcd.begin(LCD_C, LCD_R);
lcd.clear();
lcd.setCursor(0,0);
} // end PrintBegin
void PrintMessage()
{
GetTime();
Serial.print("Took "); Serial.print(time); Serial.println(" ms");
lcd.setBacklight(WHITE);
}
// end PrintMessage
// ReadButtons
void ReadButtons()
{
uint8_t buttons = lcd.readButtons();
if (buttons) {
lcd.clear();
lcd.setCursor(0,0);
if (buttons & BUTTON_UP) {
lcd.print("UP ");
lcd.setBacklight(RED);
}
if (buttons & BUTTON_DOWN) {
lcd.print("DOWN ");
lcd.setBacklight(RED);
}
if (buttons & BUTTON_LEFT) {
lcd.print("LEFT ");
lcd.setBacklight(RED);
}
if (buttons & BUTTON_RIGHT) {
lcd.print("RIGHT ");
lcd.setBacklight(RED);
}
if (buttons & BUTTON_SELECT) {
lcd.print("SELECT ");
lcd.setBacklight(RED);
}
}
}
// end ReadButtons
// GetTime
void GetTime()
{
int time = millis();
time = millis() - time;
} // end getTime
// serial printbegin
void SPrintBegin()
{
Serial.begin(9600);
Serial.println("Ready");
}// end SPrintBegin
This sketch will read and interpret the buttons allowing for menu control, which I will add later.
I am waiting for batteries for ther Real Time Clock module RTC, so I can ad that code and set up the master file, as well. enjoy the two pieces so far, temp/humidity sensor and lcd and button controls. peace
Vegas