<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>LeafLabs Garden &#187; Topic: DFRobot LCDshield example port</title>
		<link>http://forums.leaflabs.com/topic.php?id=1002</link>
		<description>A place to share, learn, and grow...</description>
		<language>en-US</language>
		<pubDate>Fri, 22 Jan 2016 00:07:17 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://forums.leaflabs.com/search.php</link>
		</textInput>
		<atom:link href="http://forums.leaflabs.com/rss.php?topic=1002" rel="self" type="application/rss+xml" />

		<item>
			<title>InsanityIdeas on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-11991</link>
			<pubDate>Wed, 25 Jul 2012 07:55:24 +0000</pubDate>
			<dc:creator>InsanityIdeas</dc:creator>
			<guid isPermaLink="false">11991@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I found my DF Robot LCD Shield to be a bit flaky (as others have mentioned) when using it with Olimexino STM32. I think its because it expects 5 volt inputs, I just get corrupted display suggesting that the data bus isn't being driven well enough. People have suggested work-arounds, but I dont' think the shield should be listed on WIKI as compatible, because out of the box it doesn't work. It works fine with a regular Arduino. Do DF Robot do a 3.3v capable version?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>higwoshy on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-10316</link>
			<pubDate>Sun, 22 Apr 2012 14:55:04 +0000</pubDate>
			<dc:creator>higwoshy</dc:creator>
			<guid isPermaLink="false">10316@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi, re : dim LCD&#60;/p&#62;
&#60;p&#62;I don't know if this will help, but I was playing around with a 20x4 white/blue LCD just yesterday and I had a problem with it not showing much when powered by 3.3V. From 5V it was perfect.&#60;/p&#62;
&#60;p&#62;Have you tried a charge pump circuit to get the voltage upto +5V? It consists of a couple of caps and diodes, the input being a PWM output from the Maple. It's very simple and works surprisingly well. The output is close to +6V, though it's not a perfect output. It does use one more maple pin, but I just plugged into the nearest PWM output that I was using already and this was good enough.&#60;/p&#62;
&#60;p&#62;Lookup &#34;Voltage Generating Circuits for LCD Contrast Control&#34; on search engines should point to an informative pdf. I didn't need the 10k pot.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Cyclegadget on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-10305</link>
			<pubDate>Sat, 21 Apr 2012 19:01:28 +0000</pubDate>
			<dc:creator>Cyclegadget</dc:creator>
			<guid isPermaLink="false">10305@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Sorry for the late reply. I agree the lcd is a bit dim and I think it is because of the STM board being 3v3 instead of 5v. &#60;/p&#62;
&#60;p&#62; The only advice I can give is that when I use lcd.clear() too frequently, it make the lcd even dimmer. &#60;/p&#62;
&#60;p&#62; I don't know if there is anything else you can do to help contrast. (
&#60;/p&#62;</description>
		</item>
		<item>
			<title>stumo on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-10267</link>
			<pubDate>Wed, 18 Apr 2012 06:59:47 +0000</pubDate>
			<dc:creator>stumo</dc:creator>
			<guid isPermaLink="false">10267@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I have the DFRobot LCD and Olimexino STM32, but the display contrast is very dim, so much so that it is very hard to read.  The pot on the board doesn't help.  I guess its a 5V LCD board being driven at 3V3 by the Olimexino.  &#60;/p&#62;
&#60;p&#62;So is there some way I can make the contrast better?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gbulmer on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-8234</link>
			<pubDate>Fri, 17 Feb 2012 18:30:56 +0000</pubDate>
			<dc:creator>gbulmer</dc:creator>
			<guid isPermaLink="false">8234@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Cyclegadget - I added backquote characters around your code so that layout is preserved.&#60;br /&#62;
LeafLabs ask that folks to use pastebin for code so that posts are a bit shorter.&#60;/p&#62;
&#60;p&#62;(Full disclosure: I am not a member of LeafLabs staff)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Cyclegadget on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-8208</link>
			<pubDate>Wed, 15 Feb 2012 23:22:07 +0000</pubDate>
			<dc:creator>Cyclegadget</dc:creator>
			<guid isPermaLink="false">8208@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Here is a working test sketch that shows the cursor position working on both lines:&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;#include &#38;lt;LiquidCrystal.h&#38;gt;

#include &#38;quot;libmaple.h&#38;quot;

int lastDebounceTime = 0;   // the last time the output pin was toggled
int debounceDelay = 80;     // the debounce time; increase if the output flickers

//Key message
char msgs[5][15] = {
  &#38;quot;Right Key  &#38;quot;,
  &#38;quot;Up Key &#38;quot;,
  &#38;quot;Down Key &#38;quot;,
  &#38;quot;Left Key  &#38;quot;,
  &#38;quot;Select Key &#38;quot; };
int adc_key_val[5] ={
  30*4, 195*4, 368*4, 545*4, 780*4 };
int NUM_KEYS = 5;
int adc_key_in;
int keypadPin = 15;//adc pin input for key function
int key=-1;
int oldkey=-1;
const int numRows = 2;
const int numCols = 16;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  // set up the LCD&#38;#39;s number of columns and rows
  lcd.begin(numCols,numRows);
  lcd.clear();
  lcd.print(&#38;quot;KEYPAD testing.&#38;quot;);
  delay(2000);
 lcd.setCursor(0, 1);   //(thisRow,thisCol)
 lcd.print(&#38;quot;Working???&#38;quot;);
 delay(2000);
 lcd.clear();
  lcd.setCursor(1,0);   //(thisRow,thisCol)
  lcd.print(&#38;quot;Yes it is good&#38;quot;);
  delay(2000);
  lcd.setCursor(0, 1);   //(thisRow,thisCol)
 lcd.print(&#38;quot;Wonderful!!!&#38;quot;);

}

void loop() {

  adc_key_in = analogRead(keypadPin); // read the value from the sensor
  SerialUSB.println( adc_key_in);

  key = get_key(adc_key_in); // convert into key press

  if (key != oldkey) // if keypress is detected
  {
    oldkey = key;
    lastDebounceTime = millis();
  }
  if ((millis() - lastDebounceTime) &#38;gt; debounceDelay) {
    adc_key_in = analogRead(keypadPin); // read the value from the sensor
    key = get_key(adc_key_in); // convert into key press
    if (key == oldkey)
    {

      if (key &#38;gt;=0)
      {
        key = get_key(adc_key_in); // convert into key press
        lcd.clear();
        lcd.setCursor(2, 0); //line=2, x=0
        lcd.print(msgs[key]);
      }
    }

  }
}

// Convert ADC value to key number
int get_key(int input)
{
  int k;

  for (k = 0; k &#38;lt; NUM_KEYS; k++)
  {
    if (input &#38;lt; adc_key_val[k])
    {

      return k;
    }
  }

  if (k &#38;gt;= NUM_KEYS)
    k = -1; // No valid key pressed

  return k;
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Cyclegadget on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-8207</link>
			<pubDate>Wed, 15 Feb 2012 23:20:28 +0000</pubDate>
			<dc:creator>Cyclegadget</dc:creator>
			<guid isPermaLink="false">8207@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;The changes are in the area of line 109 to 147. Here is my modified library code:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#include &#38;quot;LiquidCrystal.h&#38;quot;

#include &#38;lt;stdio.h&#38;gt;
#include &#38;lt;string.h&#38;gt;
#include &#38;quot;WProgram.h&#38;quot;

// When the display powers up, it is configured as follows:
//
// 1. Display clear
// 2. Function set:
//    DL = 1; 8-bit interface data
//    N = 0; 1-line display
//    F = 0; 5x8 dot character font
// 3. Display on/off control:
//    D = 0; Display off
//    C = 0; Cursor off
//    B = 0; Blinking off
// 4. Entry mode set:
//    I/D = 1; Increment by 1
//    S = 0; No shift
//
// Note, however, that resetting the Arduino doesn&#38;#39;t reset the LCD, so we
// can&#38;#39;t assume that its in that state when a sketch starts (and the
// LiquidCrystal constructor is called).

// This library has been modified to be compatible with the LeafLabs Maple;
// very conservative timing is used due to problems with delayMicroseconds()
// that should be fixed in the 0.0.7 release of the libmaple. [bnewbold]

LiquidCrystal::LiquidCrystal(uint8 rs, uint8 rw, uint8 enable,
                             uint8 d0, uint8 d1, uint8 d2, uint8 d3,
                             uint8 d4, uint8 d5, uint8 d6, uint8 d7)
{
  init(0, rs, rw, enable, d0, d1, d2, d3, d4, d5, d6, d7);
}

LiquidCrystal::LiquidCrystal(uint8 rs, uint8 enable,
                             uint8 d0, uint8 d1, uint8 d2, uint8 d3,
                             uint8 d4, uint8 d5, uint8 d6, uint8 d7)
{
  init(0, rs, 255, enable, d0, d1, d2, d3, d4, d5, d6, d7);
}

LiquidCrystal::LiquidCrystal(uint8 rs, uint8 rw, uint8 enable,
                             uint8 d0, uint8 d1, uint8 d2, uint8 d3)
{
  init(1, rs, rw, enable, d0, d1, d2, d3, 0, 0, 0, 0);
}

LiquidCrystal::LiquidCrystal(uint8 rs,  uint8 enable,
                             uint8 d0, uint8 d1, uint8 d2, uint8 d3)
{
  init(1, rs, 255, enable, d0, d1, d2, d3, 0, 0, 0, 0);
}

void LiquidCrystal::init(uint8 fourbitmode, uint8 rs, uint8 rw, uint8 enable,
                         uint8 d0, uint8 d1, uint8 d2, uint8 d3,
                         uint8 d4, uint8 d5, uint8 d6, uint8 d7)
{
  _rs_pin = rs;
  _rw_pin = rw;
  _enable_pin = enable;

  _data_pins[0] = d0;
  _data_pins[1] = d1;
  _data_pins[2] = d2;
  _data_pins[3] = d3;
  _data_pins[4] = d4;
  _data_pins[5] = d5;
  _data_pins[6] = d6;
  _data_pins[7] = d7;

  for (int i = 0; i &#38;lt; 8 - fourbitmode * 4; i++) {
      pinMode(_data_pins[i], OUTPUT);
  }

  pinMode(_rs_pin, OUTPUT);
  // we can save 1 pin by not using RW. Indicate by passing 255 instead of pin#
  if (_rw_pin != 255) {
    pinMode(_rw_pin, OUTPUT);
  }
  pinMode(_enable_pin, OUTPUT);

  if (fourbitmode)
    _displayfunction = LCD_4BITMODE &#124; LCD_1LINE &#124; LCD_5x8DOTS;
  else
    _displayfunction = LCD_8BITMODE &#124; LCD_1LINE &#124; LCD_5x8DOTS;

  // TODO: bnewbold, re-enable this?
  begin(16, 1);
}

void LiquidCrystal::begin(uint8 cols, uint8 lines, uint8 dotsize) {
  if (lines &#38;gt; 1) {
    _displayfunction &#124;= LCD_2LINE;
  }
  _numlines = lines;
  _currline = 0;

  // for some 1 line displays you can select a 10 pixel high font
  if ((dotsize != 0) &#38;amp;&#38;amp; (lines == 1)) {
    _displayfunction &#124;= LCD_5x10DOTS;
  }

  // SEE PAGE 45/46 FOR INITIALIZATION SPECIFICATION!  according to
  // datasheet, we need at least 40ms after power rises above 2.7V
  // before sending commands. Arduino can turn on way befer 4.5V so
  // we&#38;#39;ll wait 50
  delay(100);    // Maple mod
  //delayMicroseconds(50000);
  // Now we pull both RS and R/W low to begin commands
  digitalWrite(_rs_pin, LOW);
  digitalWrite(_enable_pin, LOW);
  if (_rw_pin != 255) {
    digitalWrite(_rw_pin, LOW);
  }

  //put the LCD into 4 bit or 8 bit mode
  if (! (_displayfunction &#38;amp; LCD_8BITMODE)) {
    // this is according to the hitachi HD44780 datasheet
    // figure 24, pg 46

    // we start in 8bit mode, try to set 4 bit mode
    write4bits(0x03);
    delay(50);   // Maple mod
    //delayMicroseconds(4500); // wait min 4.1ms

    // second try
    write4bits(0x03);
    delay(50);   // Maple mod
    //delayMicroseconds(4500); // wait min 4.1ms

    // third go!
    write4bits(0x03);
    delay(10);   // Maple mod
    //delayMicroseconds(150);

    // finally, set to 8-bit interface
    write4bits(0x02);
  } else {
    // this is according to the hitachi HD44780 datasheet
    // page 45 figure 23

    // Send function set command sequence
    command(LCD_FUNCTIONSET &#124; _displayfunction);
    delay(50);   // Maple mod
    //delayMicroseconds(4500);  // wait more than 4.1ms

    // second try
    command(LCD_FUNCTIONSET &#124; _displayfunction);
    delay(1);   // Maple mod
    //delayMicroseconds(150);

    // third go
    command(LCD_FUNCTIONSET &#124; _displayfunction);
  }

  // finally, set # lines, font size, etc.
  command(LCD_FUNCTIONSET &#124; _displayfunction);

  // turn the display on with no cursor or blinking default
  _displaycontrol = LCD_DISPLAYON &#124; LCD_CURSOROFF &#124; LCD_BLINKOFF;
  display();

  // clear it off
  clear();

  // Initialize to default text direction (for romance languages)
  _displaymode = LCD_ENTRYLEFT &#124; LCD_ENTRYSHIFTDECREMENT;
  // set the entry mode
  command(LCD_ENTRYMODESET &#124; _displaymode);

}

/********** high level commands, for the user! */
void LiquidCrystal::clear()
{
  command(LCD_CLEARDISPLAY);  // clear display, set cursor position to zero
  delay(20);     // Maple mod
  //delayMicroseconds(2000);  // this command takes a long time!
}

void LiquidCrystal::home()
{
  command(LCD_RETURNHOME);  // set cursor position to zero
  delay(2);     // Maple mod
  //delayMicroseconds(2000);  // this command takes a long time!
}

void LiquidCrystal::setCursor(uint8 col, uint8 row)
{
  int row_offsets[] = { 0x00, 0x40, 0x14, 0x54 };
  if ( row &#38;gt; _numlines ) {
    row = _numlines-1;    // we count rows starting w/0
  }

  command(LCD_SETDDRAMADDR &#124; (col + row_offsets[row]));
}

// Turn the display on/off (quickly)
void LiquidCrystal::noDisplay() {
  _displaycontrol &#38;amp;= ~LCD_DISPLAYON;
  command(LCD_DISPLAYCONTROL &#124; _displaycontrol);
}
void LiquidCrystal::display() {
  _displaycontrol &#124;= LCD_DISPLAYON;
  command(LCD_DISPLAYCONTROL &#124; _displaycontrol);
}

// Turns the underline cursor on/off
void LiquidCrystal::noCursor() {
  _displaycontrol &#38;amp;= ~LCD_CURSORON;
  command(LCD_DISPLAYCONTROL &#124; _displaycontrol);
}
void LiquidCrystal::cursor() {
  _displaycontrol &#124;= LCD_CURSORON;
  command(LCD_DISPLAYCONTROL &#124; _displaycontrol);
}

// Turn on and off the blinking cursor
void LiquidCrystal::noBlink() {
  _displaycontrol &#38;amp;= ~LCD_BLINKON;
  command(LCD_DISPLAYCONTROL &#124; _displaycontrol);
}
void LiquidCrystal::blink() {
  _displaycontrol &#124;= LCD_BLINKON;
  command(LCD_DISPLAYCONTROL &#124; _displaycontrol);
}

// These commands scroll the display without changing the RAM
void LiquidCrystal::scrollDisplayLeft(void) {
  command(LCD_CURSORSHIFT &#124; LCD_DISPLAYMOVE &#124; LCD_MOVELEFT);
}
void LiquidCrystal::scrollDisplayRight(void) {
  command(LCD_CURSORSHIFT &#124; LCD_DISPLAYMOVE &#124; LCD_MOVERIGHT);
}

// This is for text that flows Left to Right
void LiquidCrystal::leftToRight(void) {
  _displaymode &#124;= LCD_ENTRYLEFT;
  command(LCD_ENTRYMODESET &#124; _displaymode);
}

// This is for text that flows Right to Left
void LiquidCrystal::rightToLeft(void) {
  _displaymode &#38;amp;= ~LCD_ENTRYLEFT;
  command(LCD_ENTRYMODESET &#124; _displaymode);
}

// This will &#38;#39;right justify&#38;#39; text from the cursor
void LiquidCrystal::autoscroll(void) {
  _displaymode &#124;= LCD_ENTRYSHIFTINCREMENT;
  command(LCD_ENTRYMODESET &#124; _displaymode);
}

// This will &#38;#39;left justify&#38;#39; text from the cursor
void LiquidCrystal::noAutoscroll(void) {
  _displaymode &#38;amp;= ~LCD_ENTRYSHIFTINCREMENT;
  command(LCD_ENTRYMODESET &#124; _displaymode);
}

// Allows us to fill the first 8 CGRAM locations
// with custom characters
void LiquidCrystal::createChar(uint8 location, uint8 charmap[]) {
  location &#38;amp;= 0x7; // we only have 8 locations 0-7
  command(LCD_SETCGRAMADDR &#124; (location &#38;lt;&#38;lt; 3));
  for (int i=0; i&#38;lt;8; i++) {
    write(charmap[i]);
  }
}

/*********** mid level commands, for sending data/cmds */

inline void LiquidCrystal::command(uint8 value) {
  send(value, LOW);
}

inline void LiquidCrystal::write(uint8 value) {
  send(value, HIGH);
}

/************ low level data pushing commands **********/

// write either command or data, with automatic 4/8-bit selection
void LiquidCrystal::send(uint8 value, uint8 mode) {
  digitalWrite(_rs_pin, mode);

  // if there is a RW pin indicated, set it low to Write
  if (_rw_pin != 255) {
    digitalWrite(_rw_pin, LOW);
  }

  if (_displayfunction &#38;amp; LCD_8BITMODE) {
    write8bits(value);
  } else {
    write4bits(value&#38;gt;&#38;gt;4);
    write4bits(value);
  }
}

void LiquidCrystal::pulseEnable(void) {
  // _enable_pin should already be LOW (unless someone else messed
  // with it), so don&#38;#39;t sit around waiting for long.
  digitalWrite(_enable_pin, LOW);
  delayMicroseconds(1);

  // Enable pulse must be &#38;gt; 450 ns.  Value chosen here according to
  // the following threads:
  // &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=640&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=640&#60;/a&#62;
  // &#60;a href=&#34;http://forums.leaflabs.com/topic.php?id=512&#34; rel=&#34;nofollow&#34;&#62;http://forums.leaflabs.com/topic.php?id=512&#60;/a&#62;
  togglePin(_enable_pin);
  delayMicroseconds(1);
  togglePin(_enable_pin);

  // Commands needs &#38;gt; 37us to settle.
  delayMicroseconds(42);
}

void LiquidCrystal::write4bits(uint8 value) {
  for (int i = 0; i &#38;lt; 4; i++) {
    digitalWrite(_data_pins[i], (value &#38;gt;&#38;gt; i) &#38;amp; 0x01);
  }

  pulseEnable();
}

void LiquidCrystal::write8bits(uint8 value) {
  for (int i = 0; i &#38;lt; 8; i++) {
    digitalWrite(_data_pins[i], (value &#38;gt;&#38;gt; i) &#38;amp; 0x01);
  }

  pulseEnable();
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Cyclegadget on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-8206</link>
			<pubDate>Wed, 15 Feb 2012 23:18:13 +0000</pubDate>
			<dc:creator>Cyclegadget</dc:creator>
			<guid isPermaLink="false">8206@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I have solved my issues with the DFRobot LCD Shield and perhaps other LCD devices using the 4bit Mod!&#60;/p&#62;
&#60;p&#62; To make a long story short, the library did not allow enough delay between commands when initializing the LCD. I added more delay time to the library .cpp and now I can set the cursor with no problems!&#60;/p&#62;
&#60;p&#62; I found documentation related to LCD's and LCD Initialization.&#60;br /&#62;
Here is the link: &#60;a href=&#34;http://web.alfredstate.edu/weimandn/lcd/lcd_initialization/lcd_initialization_index.html&#34; rel=&#34;nofollow&#34;&#62;http://web.alfredstate.edu/weimandn/lcd/lcd_initialization/lcd_initialization_index.html&#60;/a&#62;
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Cyclegadget on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-7955</link>
			<pubDate>Mon, 30 Jan 2012 18:53:09 +0000</pubDate>
			<dc:creator>Cyclegadget</dc:creator>
			<guid isPermaLink="false">7955@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;This code will only use the first line of the LCD. It will not work at all unless I comment out this lcd.begin(16, 2);   &#60;/p&#62;
&#60;p&#62;Any suggestions are welcome.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;#include &#38;lt;LiquidCrystal.h&#38;gt;
#include &#38;lt;LCDKeypad.h&#38;gt;
#include &#38;quot;libmaple.h&#38;quot;

#define MINVAL 1
#define MAXVAL 1000

LCDKeypad lcd;

byte c_up[8] = {
  B00100,
  B01110,
  B10101,
  B00100,
  B00100,
  B00100,
  B00100,
  B00100,
};

byte c_down[8] = {
  B00100,
  B00100,
  B00100,
  B00100,
  B00100,
  B10101,
  B01110,
  B00100,
};

byte c_select[8] = {
  B00000,
  B01110,
  B11111,
  B11111,
  B11111,
  B11111,
  B01110,
  B00000,
};

void setup()
{
  int i,k;

  lcd.createChar(1,c_select);
  lcd.createChar(2,c_up);
  lcd.createChar(3,c_down);
 // lcd.begin(16, 2);
  lcd.clear();
  lcd.print(&#38;quot;     Guess&#38;quot;);
  lcd.setCursor(0,1);
  lcd.print(&#38;quot;   The Number&#38;quot;);
  delay(3000);
  for (k=0;k&#38;lt;3;k++)
  {
    lcd.scrollDisplayLeft();
    delay(200);
  }
  for (i=0;i&#38;lt;3;i++)
  {
    for (k=0;k&#38;lt;6;k++)
    {
      lcd.scrollDisplayRight();
      delay(200);
    }
    for (k=0;k&#38;lt;6;k++)
    {
      lcd.scrollDisplayLeft();
      delay(200);
    }
  }
  for (k=0;k&#38;lt;16;k++)
  {
    lcd.scrollDisplayLeft();
    delay(200);
  }
}

void loop()
{
  int bottom=MINVAL, top=MAXVAL;
  int trynumber=0;
  int guess, buttonPressed;

  lcd.clear();
  lcd.print(&#38;quot;Make up a number&#38;quot;);
  lcd.setCursor(0,1);
  lcd.print(&#38;quot;from &#38;quot;);
  lcd.print(MINVAL,DEC);
  lcd.print(&#38;quot; to &#38;quot;);
  lcd.print(MAXVAL,DEC);
  lcd.print(&#38;quot; &#38;quot;);
  waitButton();
  waitReleaseButton();
  do
  {
    lcd.clear();
    guess=bottom+(top-bottom)/2;
    trynumber++;

    lcd.print(&#38;quot;Is it &#38;quot;);
    lcd.print(guess,DEC);
    lcd.print(&#38;quot;?&#38;quot;);
    lcd.setCursor(0,1);
    lcd.write(1);
    lcd.write(&#38;#39; &#38;#39;);
    lcd.write(2);
    lcd.write(&#38;#39; &#38;#39;);
    lcd.write(3);
    lcd.write(&#38;#39; &#38;#39;);
    do
    {
      buttonPressed=waitButton();
    }
    while(!(buttonPressed==KEYPAD_SELECT &#124;&#124; buttonPressed==KEYPAD_UP &#124;&#124; buttonPressed==KEYPAD_DOWN));
    lcd.setCursor(0,1);
    lcd.write(buttonPressed==KEYPAD_SELECT?1:&#38;#39; &#38;#39;);
    lcd.write(&#38;#39; &#38;#39;);
    lcd.write(buttonPressed==KEYPAD_UP?2:&#38;#39; &#38;#39;);
    lcd.write(&#38;#39; &#38;#39;);
    lcd.write(buttonPressed==KEYPAD_DOWN?3:&#38;#39; &#38;#39;);
    delay(100);
    waitReleaseButton();
    if (buttonPressed==KEYPAD_UP)
    {
      bottom=constrain(guess+1,MINVAL,top);
    }
    else if (buttonPressed==KEYPAD_DOWN)
    {
      top=constrain(guess-1,bottom,MAXVAL);
    }
  }
  while (buttonPressed!=KEYPAD_SELECT &#38;amp;&#38;amp; top!=bottom);
  lcd.clear();
  if (top==bottom)
  {
    lcd.print(&#38;quot;It must be &#38;quot;);
    guess=top;
  }
  else
  {
    lcd.print(&#38;quot;It is &#38;quot;);
  }
  lcd.print(guess,DEC);
  lcd.print(&#38;quot;!&#38;quot;);
  lcd.setCursor(0,1);
  lcd.print(&#38;quot;Tries: &#38;quot;);
  lcd.print(trynumber,DEC);
  lcd.print(&#38;quot; &#38;quot;);
  waitButton();
  waitReleaseButton();
}

int waitButton()
{
  int buttonPressed;
  waitReleaseButton;
  lcd.blink();
  while((buttonPressed=lcd.button())==KEYPAD_NONE)
  {
  }
  delay(50);
  lcd.noBlink();
  return buttonPressed;
}

void waitReleaseButton()
{
  delay(50);
  while(lcd.button()!=KEYPAD_NONE)
  {
  }
  delay(50);
}&#60;/code&#62;&#60;/pre&#62;</description>
		</item>
		<item>
			<title>Cyclegadget on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-7942</link>
			<pubDate>Sun, 29 Jan 2012 22:08:18 +0000</pubDate>
			<dc:creator>Cyclegadget</dc:creator>
			<guid isPermaLink="false">7942@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;I have the DFRobot LCD Shield. Thanks for posting.&#60;/p&#62;
&#60;p&#62; However, the only problem is I am only able to use one line of the display. Such as lcd.setCursor(2, 0);&#60;/p&#62;
&#60;p&#62;If I want to use the next line lcd.setCursor(2, 1);...the text does not appear on the screen.&#60;/p&#62;
&#60;p&#62; I think the problem is in this area:&#60;br /&#62;
//lcd.init();&#60;br /&#62;
//optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()&#60;/p&#62;
&#60;p&#62;Can anyone help?&#60;/p&#62;
&#60;p&#62;Thanks,&#60;br /&#62;
Mark
&#60;/p&#62;</description>
		</item>
		<item>
			<title>mbolivar on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-6117</link>
			<pubDate>Mon, 29 Aug 2011 18:17:26 +0000</pubDate>
			<dc:creator>mbolivar</dc:creator>
			<guid isPermaLink="false">6117@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;Hi supermac,&#60;/p&#62;
&#60;p&#62;Thanks for posting!  This seems like a good addition for the &#60;a href=&#34;http://wiki.leaflabs.com/index.php?title=Compatible_Shields&#34;&#62;Compatible Shields&#60;/a&#62; page in our wiki; would you please add it?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>supermac on "DFRobot LCDshield example port"</title>
			<link>http://forums.leaflabs.com/topic.php?id=1002#post-6096</link>
			<pubDate>Sat, 27 Aug 2011 09:14:44 +0000</pubDate>
			<dc:creator>supermac</dc:creator>
			<guid isPermaLink="false">6096@http://forums.leaflabs.com/</guid>
			<description>&#60;p&#62;This is a port for the DFRobot LCD Shield example with the five buttons.  This code uses the LCD to test the buttons and is a great place to start for your simple device.  ADC values and pins are correct for the Maple.&#60;br /&#62;
Tested on the maple and the olimexino STM.&#60;/p&#62;
&#60;p&#62;#include &#38;lt;LiquidCrystal.h&#38;gt;&#60;/p&#62;
&#60;p&#62;#include &#34;libmaple.h&#34;&#60;/p&#62;
&#60;p&#62;//Key message&#60;br /&#62;
char msgs[5][15] = {&#34;Right Key OK &#34;,&#60;br /&#62;
                    &#34;Up Key OK    &#34;,&#60;br /&#62;
                    &#34;Down Key OK  &#34;,&#60;br /&#62;
                    &#34;Left Key OK  &#34;,&#60;br /&#62;
                    &#34;Select Key OK&#34; };&#60;br /&#62;
int  adc_key_val[5] ={30*4, 150*4, 360*4, 535*4, 760*4 };&#60;br /&#62;
int NUM_KEYS = 5;&#60;br /&#62;
int adc_key_in;&#60;br /&#62;
int keypadPin = 15;//adc pin input for key function&#60;br /&#62;
int key=-1;&#60;br /&#62;
int oldkey=-1;&#60;br /&#62;
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);&#60;/p&#62;
&#60;p&#62;void setup() {&#60;br /&#62;
  pinMode(13, OUTPUT);  //we'll use the debug LED to output a heartbeat&#60;/p&#62;
&#60;p&#62;  //lcd.init();&#60;br /&#62;
  //optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()&#60;br /&#62;
  //lcd.commandWrite(0x0F);//cursor on, display on, blink on.  (nasty!)&#60;br /&#62;
  lcd.clear();&#60;br /&#62;
  lcd.print(&#34;KEYPAD testing... pressing&#34;);&#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;void loop() {&#60;/p&#62;
&#60;p&#62;	adc_key_in = analogRead(keypadPin);    // read the value from the sensor&#60;br /&#62;
  digitalWrite(13, HIGH);&#60;br /&#62;
  key = get_key(adc_key_in);		        // convert into key press&#60;/p&#62;
&#60;p&#62;	if (key != oldkey)				    // if keypress is detected&#60;br /&#62;
	{&#60;br /&#62;
    delay(50);		// wait for debounce time&#60;br /&#62;
		adc_key_in = analogRead(keypadPin);    // read the value from the sensor&#60;br /&#62;
    key = get_key(adc_key_in);		        // convert into key press&#60;br /&#62;
    if (key != oldkey)&#60;br /&#62;
    {&#60;br /&#62;
      oldkey = key;&#60;br /&#62;
      if (key &#38;gt;=0)&#60;br /&#62;
      {&#60;br /&#62;
        lcd.clear();&#60;br /&#62;
        lcd.setCursor(2, 0);  //line=2, x=0&#60;br /&#62;
        lcd.print(msgs[key]);&#60;br /&#62;
      }&#60;br /&#62;
    }&#60;br /&#62;
  }&#60;/p&#62;
&#60;p&#62;  //delay(1000);&#60;br /&#62;
  digitalWrite(13, LOW);&#60;/p&#62;
&#60;p&#62;}&#60;/p&#62;
&#60;p&#62;// Convert ADC value to key number&#60;br /&#62;
int get_key(int input)&#60;br /&#62;
{&#60;br /&#62;
	int k;&#60;/p&#62;
&#60;p&#62;	for (k = 0; k &#38;lt; NUM_KEYS; k++)&#60;br /&#62;
	{&#60;br /&#62;
		if (input &#38;lt; adc_key_val[k])&#60;br /&#62;
		{&#60;/p&#62;
&#60;p&#62;    return k;&#60;br /&#62;
        }&#60;br /&#62;
	}&#60;/p&#62;
&#60;p&#62;    if (k &#38;gt;= NUM_KEYS)&#60;br /&#62;
        k = -1;     // No valid key pressed&#60;/p&#62;
&#60;p&#62;    return k;&#60;br /&#62;
}
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
