Go Down

Topic: 1st Attempt.. SainSmart Display (Read 2286 times) previous topic - next topic

twinturbo

I am embarking on my first try out of Uno with a Sain Uno board, SainSmart Keypad/LCD sheild.

I am using their example code and libraries,

at first the ?sketch?  failed the verify and I guessed from my ancient proggraming knowledge that it needed the missing included library LCDKeypad.

So I copied in the files into a folder in the libraries directory and it seems to include the files ok but the compile failes with


LCDKeypad/LCDKeypad.cpp.o: In function `LCDKeypad::LCDKeypad()':
/usr/share/arduino/libraries/LCDKeypad/LCDKeypad.cpp:12: multiple definition of `LCDKeypad::button()'
LCDKeypad.cpp.o:LCDKeypad.cpp:12: first defined here
LCDKeypad/LCDKeypad.cpp.o: In function `LCDKeypad::LCDKeypad()':
/usr/share/arduino/libraries/LCDKeypad/LCDKeypad.cpp:12: multiple definition of `LCDKeypad::LCDKeypad()'
LCDKeypad.cpp.o:LCDKeypad.cpp:12: first defined here
LCDKeypad/LCDKeypad.cpp.o: In function `LCDKeypad::LCDKeypad()':
/usr/share/arduino/libraries/LCDKeypad/LCDKeypad.cpp:12: multiple definition of `LCDKeypad::LCDKeypad()'
LCDKeypad.cpp.o:LCDKeypad.cpp:12: first defined here


Searched Google but nothing came back that was helpful.

Any pointers to get me going ?

Cheers

Rob

johnwasser

Looks like the LCDKeypad library got included twice.  Search to make sure you only have one copy on your disk.

A pointer to the example sketch and libraries might help.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

twinturbo

Thanks for the reply.

The sketch is the "Guessthenumber" from sainsmarts library

http://www.sainsmart.com/module/lcd-module/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.html

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

#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("     Guess");
  lcd.setCursor(0,1);
  lcd.print("   The Number");
  delay(3000);
  for (k=0;k<3;k++)
  {
    lcd.scrollDisplayLeft();
    delay(200);
  }
  for (i=0;i<3;i++)
  {
    for (k=0;k<6;k++)
    {
      lcd.scrollDisplayRight();
      delay(200);
    }
    for (k=0;k<6;k++)
    {
      lcd.scrollDisplayLeft();
      delay(200);
    }
  }
  for (k=0;k<16;k++)
  {
    lcd.scrollDisplayLeft();
    delay(200);
  }
}

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

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

    lcd.print("Is it ");
    lcd.print(guess,DEC);
    lcd.print("?");
    lcd.setCursor(0,1);
    lcd.write(1);
    lcd.write(' ');
    lcd.write(2);
    lcd.write(' ');
    lcd.write(3);
    lcd.write(' ');
    do
    {
      buttonPressed=waitButton();
    }
    while(!(buttonPressed==KEYPAD_SELECT || buttonPressed==KEYPAD_UP || buttonPressed==KEYPAD_DOWN));
    lcd.setCursor(0,1);
    lcd.write(buttonPressed==KEYPAD_SELECT?1:' ');
    lcd.write(' ');
    lcd.write(buttonPressed==KEYPAD_UP?2:' ');
    lcd.write(' ');
    lcd.write(buttonPressed==KEYPAD_DOWN?3:' ');
    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 && top!=bottom);
  lcd.clear();
  if (top==bottom)
  {
    lcd.print("It must be ");
    guess=top;
  }
  else
  {
    lcd.print("It is ");
  }
  lcd.print(guess,DEC);
  lcd.print("!");
  lcd.setCursor(0,1);
  lcd.print("Tries: ");
  lcd.print(trynumber,DEC);
  lcd.print(" ");
  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);
}






Cheers

Rob

twinturbo

I shall check the library folder later to see if there is more than one instance of the library.

Rob

johnwasser

I downloaded "LCD1602.rar", expanded it, expanded LCD1602/LCDKeypad.zip and moved the resulting LCD1602/LCDKeypad folder to Arduino/libraries/LCDKeypad.  When I compiled the "GuessTheNumber" example (File->Examples->LCDKeypad->GuessTheNumber) the first error I got was:

Arduino/libraries/LCDKeypad/LCDKeypad.cpp:5:22: error: WProgram.h: No such file or directory

That indicates that the library was not updated for Arduino 1.0.  I changes "WProgram.h" to "Arduino.h" and the example then compiled just fine.

I did NOT install the "LCD4Bit_mod" library because the keypad example uses the built-in "LiquidCrystal.h".
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

twinturbo

Ok thanks for the info, sound like I am making a basic mistake with the library somewhere.

Where did you get the RAR? I can only find ZIP's on SAINS site.

Cheers

Rob

johnwasser


Ok thanks for the info, sound like I am making a basic mistake with the library somewhere.

Where did you get the RAR? I can only find ZIP's on SAINS site.

Cheers

Rob


Clicked on the link you provided:
http://www.sainsmart.com/module/lcd-module/sainsmart-1602-lcd-keypad-shield-for-arduino-duemilanove-uno-mega2560-mega1280.html

Downloaded the .zip on that page ("Download Link for 1602LCD Code for arduino 1.0;") but found no GuessTheNumber example in it.

Clicked on the "Document" tab and found a link labeled "Download Link".  That's the one that goes to: http://www.thesunrain.com/Amazon/LCDKeypad%20Shield/LCD1602.rar 
That .rar contains LCDKeypad.zip
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

twinturbo

YAY..

I searched the tree and as you expected found two copies of the include.

1 was the one I had put in the library and the other was in the GuessTheNumber folder.

Compied and uploaded ..

Worked Gr8.



Thanks, my first Arduino Experience is now a success.

Took me 3 days of soldering and building on my last Microcontroler test about 7 years ago.. and that was just to sequence 4 led's

Rob

seb21051

I am very new to Arduino and very rusty as regards C.

From this example sketch:


http://arduino.cc/en/Tutorial/LiquidCrystalBlink

*/

// include the library code:

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


// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // Turn off the blinking cursor:
  lcd.noBlink();
  delay(3000);
   // Turn on the blinking cursor:
  lcd.blink();
  delay(3000);
}

I get this error:

In file included from Blink.ino:43:
C:\Users\seb\Documents\Arduino\libraries\LCDKeypad/LCDKeypad.h:18: error: expected class-name before '{' token

Looking for some guidance, please!



floresta

#9
Sep 24, 2014, 03:44 am Last Edit: Sep 24, 2014, 03:47 am by floresta Reason: 1
Quote
Looking for some guidance, please!



This thread is complete since the OP (original poster) stated "
Thanks, my first Arduino Experience is now a success."

You really should start a new thread instead of hijacking this one.

Also - you should highlight the portion of your post that consists of code and then use the '#' code button to make it look like this:

Code: [Select]
. . .
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
. . .


Don

dannable

Looks like the problem is solved

Code: [Select]
http://forum.arduino.cc/index.php?topic=268656.0
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Go Up