Forum >Replies by dweston
userhead dweston
Replies (3)
  • You Reply: [quote="wa5znu"]
    I've added a backlight method, to control the backlight on pin 10.
    It would be nice if someone would consider adding this.

    It adds one new method
      void backlight(byte level);
    as in
      lcd.backlight(128);

    [url=http://pastebin.com/qKQ2fnYc]http://pastebin.com/qKQ2fnYc[/url]

    [/quote]

    wa5znu I have attempted to carefully add the backlight method code you point to in your link above into the LCDKeypad.cpp and LCDKeypad.h files derived from the original LCDKeypad.zip library.

    The result is:
    [code]/*
      LCDKeypad.cpp
    */

    #include "WProgram.h"

    // include this library's description file

    #include <LiquidCrystal.h>
    #include "LCDKeypad.h"

    #define BACKLIGHT 10

    LCDKeypad::LCDKeypad() : LiquidCrystal(8, 9, 4, 5, 6, 7)
    {
      pinMode(BACKLIGHT, OUTPUT);
      backlight(255);
    }

    int LCDKeypad::button()
    {
      static int NUM_KEYS=5;
      static int adc_key_val[5] ={ 
        30, 150, 360, 535, 760    };
      int k, input;
      input=analogRead(0);
      for (k = 0; k < NUM_KEYS; k++)
      {
        if (input < adc_key_val[k])
        {
          return k;
        }
      }
      if (k >= NUM_KEYS)
        k = -1;    // No valid key pressed
      return k;
    }

    void LCDKeypad::backlight(byte level)
    {
      analogWrite(BACKLIGHT, level/4);
    }[/code]

    and

    [code]/*
      LCDKeypad.h
    */

    // ensure this library description is only included once
    #ifndef LCDKeypad_h
    #define LCDKeypad_h

    // library interface description
    #define KEYPAD_NONE -1
    #define KEYPAD_RIGHT 0
    #define KEYPAD_UP 1
    #define KEYPAD_DOWN 2
    #define KEYPAD_LEFT 3
    #define KEYPAD_SELECT 4

    class LCDKeypad: public LiquidCrystal
    {
      public:
        LCDKeypad();
        int button();
        void backlight(byte level);
    };

    #endif

    [/code]

    I then opened the GuessTheNumber.pde example, without modifying it in any way, in Arduino 1.0.

    But when I attempt to verify the code I encountered an error as follows:

    "In file included from LCD_GuessTheNumber.cpp:2:
    /Users/.....  /Arduino/arduino-1.0/libraries/LCDKeypad/LCDKeypad.h:22: error: 'byte' has not been declared
    "

    Could you advise what I might be missing?
  • You Reply: [quote="wa5znu"]
    I've added a backlight method, to control the backlight on pin 10.
    It would be nice if someone would consider adding this.

    It adds one new method
      void backlight(byte level);
    as in
      lcd.backlight(128);

    [url=http://pastebin.com/qKQ2fnYc]http://pastebin.com/qKQ2fnYc[/url]

    [/quote]

    wa5znu I have attempted to carefully add the backlight method code you point to in your link above into the LCDKeypad.cpp and LCDKeypad.h files derived from the original LCDKeypad.zip library.

    The result is:
    [code]/*
      LCDKeypad.cpp
    */

    #include "WProgram.h"

    // include this library's description file

    #include <LiquidCrystal.h>
    #include "LCDKeypad.h"

    #define BACKLIGHT 10

    LCDKeypad::LCDKeypad() : LiquidCrystal(8, 9, 4, 5, 6, 7)
    {
      pinMode(BACKLIGHT, OUTPUT);
      backlight(255);
    }

    int LCDKeypad::button()
    {
      static int NUM_KEYS=5;
      static int adc_key_val[5] ={ 
        30, 150, 360, 535, 760    };
      int k, input;
      input=analogRead(0);
      for (k = 0; k < NUM_KEYS; k++)
      {
        if (input < adc_key_val[k])
        {
          return k;
        }
      }
      if (k >= NUM_KEYS)
        k = -1;    // No valid key pressed
      return k;
    }

    void LCDKeypad::backlight(byte level)
    {
      analogWrite(BACKLIGHT, level/4);
    }[/code]

    and

    [code]/*
      LCDKeypad.h
    */

    // ensure this library description is only included once
    #ifndef LCDKeypad_h
    #define LCDKeypad_h

    // library interface description
    #define KEYPAD_NONE -1
    #define KEYPAD_RIGHT 0
    #define KEYPAD_UP 1
    #define KEYPAD_DOWN 2
    #define KEYPAD_LEFT 3
    #define KEYPAD_SELECT 4

    class LCDKeypad: public LiquidCrystal
    {
      public:
        LCDKeypad();
        int button();
        void backlight(byte level);
    };

    #endif

    [/code]

    I then opened the GuessTheNumber.pde example, without modifying it in any way, in Arduino 1.0.

    But when I attempt to verify the code I encountered an error as follows:

    "In file included from LCD_GuessTheNumber.cpp:2:
    /Users/.....  /Arduino/arduino-1.0/libraries/LCDKeypad/LCDKeypad.h:22: error: 'byte' has not been declared
    "

    Could you advise what I might be missing?
  • You Reply: [quote="wa5znu"]
    I've added a backlight method, to control the backlight on pin 10.
    It would be nice if someone would consider adding this.

    It adds one new method
      void backlight(byte level);
    as in
      lcd.backlight(128);

    [url=http://pastebin.com/qKQ2fnYc]http://pastebin.com/qKQ2fnYc[/url]

    [/quote]

    wa5znu I have attempted to carefully add the backlight method code you point to in your link above into the LCDKeypad.cpp and LCDKeypad.h files derived from the original LCDKeypad.zip library.

    The result is:
    [code]/*
      LCDKeypad.cpp
    */

    #include "WProgram.h"

    // include this library's description file

    #include <LiquidCrystal.h>
    #include "LCDKeypad.h"

    #define BACKLIGHT 10

    LCDKeypad::LCDKeypad() : LiquidCrystal(8, 9, 4, 5, 6, 7)
    {
      pinMode(BACKLIGHT, OUTPUT);
      backlight(255);
    }

    int LCDKeypad::button()
    {
      static int NUM_KEYS=5;
      static int adc_key_val[5] ={ 
        30, 150, 360, 535, 760    };
      int k, input;
      input=analogRead(0);
      for (k = 0; k < NUM_KEYS; k++)
      {
        if (input < adc_key_val[k])
        {
          return k;
        }
      }
      if (k >= NUM_KEYS)
        k = -1;    // No valid key pressed
      return k;
    }

    void LCDKeypad::backlight(byte level)
    {
      analogWrite(BACKLIGHT, level/4);
    }[/code]

    and

    [code]/*
      LCDKeypad.h
    */

    // ensure this library description is only included once
    #ifndef LCDKeypad_h
    #define LCDKeypad_h

    // library interface description
    #define KEYPAD_NONE -1
    #define KEYPAD_RIGHT 0
    #define KEYPAD_UP 1
    #define KEYPAD_DOWN 2
    #define KEYPAD_LEFT 3
    #define KEYPAD_SELECT 4

    class LCDKeypad: public LiquidCrystal
    {
      public:
        LCDKeypad();
        int button();
        void backlight(byte level);
    };

    #endif

    [/code]

    I then opened the GuessTheNumber.pde example, without modifying it in any way, in Arduino 1.0.

    But when I attempt to verify the code I encountered an error as follows:

    "In file included from LCD_GuessTheNumber.cpp:2:
    /Users/.....  /Arduino/arduino-1.0/libraries/LCDKeypad/LCDKeypad.h:22: error: 'byte' has not been declared
    "

    Could you advise what I might be missing?