OSEPP LCD shield w/ Shield Shield and particle

Hey friends,

I am trying to get the OSEPP 16 X 2 LCD shield to work with the shield shield that arrived today. I have found Source) some a simple Arduino example code and am having trouble getting to to respond on the hardware, even though it compiles and flashes fine.

my real question is is there any problems that could arise from using a code built for arduino on the particle cloud platform? Any help is greatly appreciated.

here is the code i found:

//Sample using LiquidCrystal library
#include <LiquidCrystal.h>
 
// 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
 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;
 }
 }
 
}

Post a picture showing how you have it wired up.

@jjlee32, the port is not always one-to-one. In your case, this means:

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

Will not work unless you specify valid Photon pin values. The same problem exists here:

adc_key_in = analogRead(0);      // read the value from the sensor

Will need to be modified to specify a correct Photon pin (A0, A1, A2, etc). Also, the ADC on the Photon is 12bits whereas a typical Arduino ADC is 10bits so all the adc_key_in value comparisons will need to be adjusted to reflect 12bit range values. :smile:

Thanks I’ve pulled up the data sheet on the Shield Shield and matched the pins so its displaying characters now. The pins for the photon for someone who may have had the same issue are

LiquidCrystal lcd(A5, A4, D6, D0, D1, D7);

My new issue is that when I simplify the code to just simply display “hello, world!”( I didn’t want to delve so deep as to figure out converting the resolutions). The characters aren’t all correct. It is displaying “hdlln, fnbld” any suggestions on how to figure this one out?

If your board looks anything like this one, you could use that library

This lib also contains this comment


/*
  Arduino KeyPad LCD Shield Library - Basic Menu
 
 Demonstrates the use a 16x2 LCD display and the five button KeyPad.
 The LiquidCrystal library works with all LCD displays that are 
 compatible with the Hitachi HD44780 driver. There are many of them out 
 there, and you can usually tell them by the 16-pin interface.
 
 This sketch provides a rudementary implementation of a four item menue 
 in the second LCD row that can be navigated with the LEFT/RIGHT/UP/DOWN 
 buttons and SELECT an item to display in the first row and expose as
 Particle.variable().
 
  Wiring for Particle Shield shield v3.0.1
  * LCD RS pin to digital pin A5
  * LCD EN pin to digital pin A4
  * LCD D4 pin to digital pin D6
  * LCD D5 pin to digital pin D0
  * LCD D6 pin to digital pin D1
  * LCD D7 pin to digital pin D7
  * KeyPad A0  to analog  pin A0 (before usage make sure shield output max 3.3V)  
 
 Copyright ScruffR 2015

 http://www.dfrobot.com/wiki/index.php/LCD_KeyPad_Shield_For_Arduino_SKU:_DFR0009
*/
2 Likes

Thank you I will try and get it to work using that library. I am still a novice if that wasnt already obvious and am wondering if there is a simple rule of thumb for using lib’s for example in the LiquidCrystal it is necessary to declare a bunch of things to get it to work. For example

LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
lcd.begin(16, 2);              // start the library
 lcd.setCursor(0,0);

the only reason these are include in the code I attached is because they were attached in the first place. My real question is how do i find these same commands for the new lib you’ve referenced, and is there a convention for that, like somewhere in the lib files that details the commands and syntax’es

Thanks again

Usually the .CPP file in the library contains all the functions you can call from the library.

And yes the 3 lines above are required. At least the first 2 lines are to get that library started.

1 Like

These “commands” are fine to use, the real “issue” are the parameters for these functions (= the numbers in parentheses).
Since you don’t necessarily need to use the Shield Shield you could choose any combination of pins for your display and there is no way the library contributor could know beforehand which pin combination you will go for. Hence you need to tell the library what you chose.

I’ve managed to get it to work with both libraries. However, it is still messing the up the string am i trying to display on it. As i mentioned above when trying to display “hello, world!” it displays “hdlln, fnbld”. Thanks again for all your help

This might be an issue with speed and/or bad contacts.