2013-03-21

Arduino LCD: Run on DFRobot LCD Shields.

Simon Baker (TinkerTronics) sent me the following code to get the Arduino game conversions running using the DFRobot LCD Keypad Shield. Just replace the relevant code at the top of the file and uncomment the #define DFROBOT_LCD line.

You'll notice that the ADC reading are slightly different. Enjoy!

/*--------------------------------------------------------------------------------------
 Defines
 --------------------------------------------------------------------------------------*/

// uncomment the next line to enable settings for the DFRobot LCD Shield -by Simon Baker
// #define DFROBOT_LCD 

// Pins in use
#define BUTTON_ADC_PIN           A0  // A0 is the button ADC input
#define LCD_BACKLIGHT_PIN         3  // D3 controls LCD backlight

#ifdef DFROBOT_LCD
  // ADC readings expected for the 5 buttons on the ADC input
  #define RIGHT_10BIT_ADC           0  // right
  #define UP_10BIT_ADC            99  // up
  #define DOWN_10BIT_ADC          256  // down
  #define LEFT_10BIT_ADC          410  // left
  #define SELECT_10BIT_ADC        640  // right
#else
  // ADC readings expected for the 5 buttons on the ADC input
  #define RIGHT_10BIT_ADC           0  // right
  #define UP_10BIT_ADC            145  // up
  #define DOWN_10BIT_ADC          329  // down
  #define LEFT_10BIT_ADC          505  // left
  #define SELECT_10BIT_ADC        741  // right
#endif

#define BUTTONHYSTERESIS         10  // hysteresis for valid button sensing window