Added backlight control through library.
This commit is contained in:
@@ -217,5 +217,6 @@ void LiquidCrystal::setBacklight ( uint8_t mode )
|
||||
// setBacklightPin
|
||||
void LiquidCrystal::setBacklightPin ( uint8_t pin )
|
||||
{
|
||||
pinMode ( pin, OUTPUT ); // Difine the backlight pin as output
|
||||
_backlightPin = pin;
|
||||
}
|
||||
|
||||
@@ -122,6 +122,8 @@ void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize)
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
// Turn the (optional) backlight off/on
|
||||
//
|
||||
// setBacklight
|
||||
void LiquidCrystal_I2C::setBacklight( uint8_t mode )
|
||||
{
|
||||
if ( mode == HIGH )
|
||||
@@ -136,6 +138,8 @@ void LiquidCrystal_I2C::setBacklight( uint8_t mode )
|
||||
_i2cio.write( _backlightMask );
|
||||
}
|
||||
|
||||
//
|
||||
// setBacklightPin
|
||||
void LiquidCrystal_I2C::setBacklightPin ( uint8_t pin )
|
||||
{
|
||||
_backlightPin = ( 1 << pin );
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
|
||||
#define CONTRAST_PIN 9
|
||||
#define BACKLIGHT_PIN 7
|
||||
#define CONTRAST 100
|
||||
#define CONTRAST 110
|
||||
|
||||
// Creat a set of new characters
|
||||
byte smiley[8] = {
|
||||
@@ -47,10 +47,10 @@ void setup()
|
||||
|
||||
// Switch on the backlight and LCD contrast levels
|
||||
pinMode(CONTRAST_PIN, OUTPUT);
|
||||
pinMode(BACKLIGHT_PIN, OUTPUT);
|
||||
analogWrite ( CONTRAST_PIN, CONTRAST );
|
||||
|
||||
digitalWrite(BACKLIGHT_PIN, HIGH);
|
||||
analogWrite (CONTRAST_PIN, CONTRAST);
|
||||
lcd.setBacklightPin ( BACKLIGHT_PIN );
|
||||
lcd.setBacklight ( HIGH );
|
||||
|
||||
lcd.begin(16,2); // initialize the lcd
|
||||
|
||||
|
||||
Reference in New Issue
Block a user