shopping cart empty
WORLDWIDE FREE SHIPPING

Arduino Example
Login to post a new topic and to write a reply.
Thread Tools Rate This Thread


Search within thread:

Login to rate this thread.
#1 (permalink)      8/29/2013 4:17:29 PM US Central   quote/reply + tips
pitor
Member
  • JoinedJul 2013
  • Posts 2
  • Reviews 0
  • Kudos2
+2 details
Arduino Example
There is no documentation in the package. Here is a working sketch. It has been tested on Arduino Uno.



#include

#define LCD_RS 8
#define LCD_EN 9
#define LCD_D4 4
#define LCD_D5 5
#define LCD_D6 6
#define LCD_D7 7
#define LCD_BACKLIGHT 10

LiquidCrystal lcd(LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7);

void setup() {
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("... init ... ");
pinMode(LCD_BACKLIGHT, OUTPUT);
//Lights on
digitalWrite( LCD_BACKLIGHT, HIGH);
delay(2000);
lcd.clear();
}

void loop() {
int i = analogRead(0);
lcd.setCursor(0,0);
lcd.print(i);
lcd.print(" ");
}
#2 (permalink)      8/29/2013 4:19:45 PM US Central   quote/reply + tips
pitor
Member
  • JoinedJul 2013
  • Posts 2
  • Reviews 0
  • Kudos2
The forum ate some of the #include line

Should have been #include LiquidCrystal.h with less than and greater than signs around LiquidCrystal.h
#3 (permalink)      1/21/2014 4:53:31 AM US Central   quote/reply + tips
CityLights
Member
  • JoinedJun 2013
  • Posts 40
  • Reviews 10
  • Kudos21
Thanks for your post, got me up and running the shield in no time!

for most other sketches, I just paste this over the old settings and it works.
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#4 (permalink)      4/26/2015 5:46:29 AM US Central   quote/reply + tips
herbwyatt
Member
  • JoinedJul 2013
  • Posts 9
  • Reviews 0
  • Kudos1
Note: Button test example
This is not my Skectch. All credit goes to Mark Bramwell, July 2010
I used v1.1 threshold but modified values as they were off for me.
Worked fine for me on Uno R3 and Mega 2560 R3 purchased here at FT.
Hope this works for all, enjoy.


//Sample using LiquidCrystal library
#include

/*******************************************************

This program will test the LCD panel and the buttons
Mark Bramwell, July 2010

********************************************************/

// select the pins used on the LCD panel
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// define some values used by the panel and buttons
int lcd_key = 0;
int adc_key_in = 0;
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5

// read the buttons
int read_LCD_buttons()
{
adc_key_in = analogRead(0); // read the value from the sensor
// my buttons when read are centered at these valies: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
// For V1.1 us this threshold
if (adc_key_in < 50) return btnRIGHT;
if (adc_key_in < 250) return btnUP;
if (adc_key_in < 350) return btnDOWN;
if (adc_key_in < 450) return btnLEFT;
if (adc_key_in < 850) return btnSELECT;

// For V1.0 comment the other threshold and use the one below:
/*
// if (adc_key_in < 50) return btnRIGHT;
// if (adc_key_in < 195) return btnUP;
// if (adc_key_in < 380) return btnDOWN;
// if (adc_key_in < 555) return btnLEFT;
// if (adc_key_in < 790) return btnSELECT;
*/


return btnNONE; // when all others fail, return this...
}

void setup()
{
lcd.begin(16, 2); // start the library
lcd.setCursor(0,0);
lcd.print("Push the buttons"); // print a simple message
}

void loop()
{
lcd.setCursor(9,1); // move cursor to second line "1" and 9 spaces over
lcd.print(millis()/1000); // display seconds elapsed since power-up


lcd.setCursor(0,1); // move to the begining of the second line
lcd_key = read_LCD_buttons(); // read the buttons

switch (lcd_key) // depending on which button was pushed, we perform an action
{
case btnRIGHT:
{
lcd.print("RIGHT ");
break;
}
case btnLEFT:
{
lcd.print("LEFT ");
break;
}
case btnUP:
{
lcd.print("UP ");
break;
}
case btnDOWN:
{
lcd.print("DOWN ");
break;
}
case btnSELECT:
{
lcd.print("SELECT");
break;
}
case btnNONE:
{
lcd.print("NONE ");
break;
}
}

}
#5 (permalink)      4/26/2015 5:54:13 AM US Central   quote/reply + tips
herbwyatt
Member
  • JoinedJul 2013
  • Posts 9
  • Reviews 0
  • Kudos1
System omitted some of the #include statement... as others have experienced...

be sure to use: #include LiquidCrystal.h with less than and greater than signs around LiquidCrystal.h
as stated by pitor.