Loading...
Pages: [1]   Go Down
Author Topic: SainSmart LCD Keypad Shield + ethernet shield  (Read 634 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


Like many others, I'm having trouble using a SainSmart LCD keypad shield in conjunction with an ethernet shield.

When stacked directly on my Arduino, I can get the LCD to display.

When stacked on top of the ethernet shield however, there's nothing output.

I read elsewhere about both shields using pin 4.

Is there anything I can do to get it to work, preferably without soldering?
Logged

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

I also have this issue.  I have an Arduino Mega2560 with ethernet shield on top, headers on top of that, sainsmart 1602 lcd w/keypad on top of that.  When I try to use both shields, it immediately fails on grabbing DHCP.  Here is my code:

Code:
#include <DNS.h>
#include <SPI.h>         
#include <Ethernet.h>
#include <EthernetUdp.h>
#include <SD.h>
#include <Time.h>
#include <Timezone.h>
#include <LiquidCrystal.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
unsigned int localPort = 8888;
IPAddress timeServer(172, 16, 0, 4);
const int NTP_PACKET_SIZE = 48;
byte packetBuffer[NTP_PACKET_SIZE];
EthernetUDP Udp;
int timeZoneHour = -5;
long timeZoneOffset = (timeZoneHour * -1) * 60 * 60;
int NTP_UPDATE_INTERVAL = 10;
int counter = 0;
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);

void resetSauce() {
 
  void (*softReset) (void) = 0; //declare reset function @ address 0
  softReset();
 
}

unsigned long sendNtpPacket(IPAddress& address) {
 
  memset(packetBuffer, 0, NTP_PACKET_SIZE);
  packetBuffer[0] = 0b11100011;
  packetBuffer[1] = 0;
  packetBuffer[2] = 6;
  packetBuffer[3] = 0xEC;
  packetBuffer[12]  = 49;
  packetBuffer[13]  = 0x4E;
  packetBuffer[14]  = 49;
  packetBuffer[15]  = 52;
  Udp.beginPacket(address, 123);
  Udp.write(packetBuffer,NTP_PACKET_SIZE);
  Udp.endPacket();
 
}

unsigned long grabNtpTime() {

  Serial.print("GRABBING NTP FROM ");
  Serial.println(timeServer);
  counter = 0;
  sendNtpPacket(timeServer);
  delay(1);
   
  if (!Udp.parsePacket()) {
   
    Serial.println("No NTP packet found");
    return 0;
     
  }
 
 
  Serial.println("SUCCESS");
  Udp.read(packetBuffer, NTP_PACKET_SIZE);
  unsigned long highWord = word(packetBuffer[40], packetBuffer[41]);
  unsigned long lowWord = word(packetBuffer[42], packetBuffer[43]);
  unsigned long secsSince1900 = highWord << 16 | lowWord;
  const unsigned long seventyYears = 2208988800UL + timeZoneOffset;
  unsigned long epoch = secsSince1900 - seventyYears;
  return epoch;

}

void printDigits(int digits) {
 
  if (digits < 10) {
   
    lcd.print('0');
 
  }
 
  lcd.print(digits);
 
}

void printDayOfWeek(int digits) {
 
  if (digits == 1) { lcd.print(" SUN"); }
  else if (digits == 2) { lcd.print(" MON"); }
  else if (digits == 3) { lcd.print(" TUE"); }
  else if (digits == 4) { lcd.print(" WED"); }
  else if (digits == 5) { lcd.print(" THU"); }
  else if (digits == 6) { lcd.print(" FRI"); }
  else if (digits == 7) { lcd.print(" SAT"); }
 
}

void printDateTime() {
 
  time_t eastern, utc;
  TimeChangeRule *tcr;
  TimeChangeRule usEDT = {"EDT", Second, Sun, Mar, 2, -240};
  TimeChangeRule usEST = {"EST", First, Sun, Nov, 2, -300};
  Timezone usEastern(usEDT, usEST);
  utc = now() + 2;
  eastern = usEastern.toLocal(utc, &tcr);
  printDayOfWeek(weekday(utc));
  lcd.print(" ");
  printDigits(hourFormat12(utc));
  lcd.print(":");
  printDigits(minute(utc));
  lcd.print(":");
  printDigits(second(utc));
 
  if (isAM()) {
   
    lcd.println(" AM");
   
  } else {
   
    lcd.println(" PM");
   
  }
 
  //Serial.println(tcr->abbrev);
 
}

void setupTime() {
 
  setSyncProvider(grabNtpTime);
 
}

void setup() {

  Serial.begin(9600);
 
  if (!Ethernet.begin(mac)) {
   
    lcd.println("DHCP FAILED");
    for(;;);
   
  }
 
  Udp.begin(localPort);
  lcd.print("IP Address [DHCP]: ");
  lcd.println(Ethernet.localIP());
  setupTime();

}

void loop() {

  printDateTime();
  delay(1000);
 
}
Logged

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


I gave up trying to use the SainSmart shield. I thought it was something to do with pin conflicts, and I found this interesting post:

http://www.martyndavis.com/?p=284


So I managed to get the ethernet shield to work unstacked by wiring it with the Arduino's ICSP pins, but still no luck with the LCD.

In the end, I got a (non-shield) display

http://www.oomlout.co.uk/lcd-display-16-x-2-p-212.html

and used that instead, wired to the stacked Arduino+Ethernet



Logged

Anaheim CA.
Offline Offline
Edison Member
*
Karma: 31
Posts: 2304
Experienced old Whitebeard with a Full head of Hair...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Liudr here in the forum sells a very nice (I have 2) RS232 "Backpack" that will work on 2 X 16 or 4 Xx 20 displays.. also has a connector for a 16 key matrix keypad... and a "Beeper". They're great for development or testing especially the keypad..  {Edit RKJ} ..

Bob
« Last Edit: March 06, 2013, 09:45:27 am by Docedison » Logged

“The solution of every problem is another problem.” -Johann Wolfgang von Goethe

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

i got it working, i basically rerouted pin 4 going to lcd shield and placed it at I believe pin 22 and just bent pin 10 going to lcd shield, all is working now.
Logged

Pages: [1]   Go Up
Print
 
Jump to: