Pages: [1]   Go Down
Author Topic: 1st Attempt.. SainSmart Display  (Read 1926 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8934
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Rob
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8934
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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".
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 212
Posts: 8934
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: