Go Down

Topic: LCD not working after UDP is initiated. (Read 970 times) previous topic - next topic

6409

Hi i am currently having issues using a '20,4' LCD display after i initiate 'Udp.begin(localPort)'. Rather than things i want to print to the LCD i only get squares on line 1 & 3.

This is the first set of code. This works fine as the Udp.begin(localPort) is after i've set the text.

Code: [Select]

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008
#include <LiquidCrystal.h>        //LCD libary


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
  lcd.begin(20,4);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("hello world");
  lcd.setCursor(0, 1);
  lcd.print("hello world");
  lcd.setCursor(0, 2);
  lcd.print("hello world");
  lcd.setCursor(0, 3);
  lcd.print("hello world");
  Udp.begin(localPort);
 
}

void loop() {}




now if i do the following with this code and move the udp section.

Code: [Select]

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008
#include <LiquidCrystal.h>        //LCD libary


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
  Udp.begin(localPort);
  lcd.begin(20,4);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("hello world");
  lcd.setCursor(0, 1);
  lcd.print("hello world");
  lcd.setCursor(0, 2);
  lcd.print("hello world");
  lcd.setCursor(0, 3);
  lcd.print("hello world");
 
}

void loop() {}


with this i only get blank squares. I have attached 2 photos of how it is to try and show you what i mean, Evidently both set compile fine and upload its just this one issue i've ran into.Also i have checked all the connections. are solder I cant just initiate UDP after printing to the LCD as some  data that arrives over UDP needs to be displayed.

If anyone has any Idea's id greatly appriciate the help.


floresta

You have to change some of the pins that you are currently using for your LCD. 

The SPI system uses pins 11, 12, and 13 so you cannot also use any of them for your LCD.  Since the SPI pins cannot be changed you have to change the LCD.


Don

6409

Thanks for the reply, the issue is now ive made the changes i get the same error.

Code: [Select]

#include <SPI.h>         // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h>         // UDP library from: bjoern@cs.stanford.edu 12/30/2008
#include <LiquidCrystal.h>        //LCD libary


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 1, 177);

unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

LiquidCrystal lcd(9, 8, 5, 4, 3, 2);
void setup() {
  Udp.begin(localPort);
  lcd.begin(20,4);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("hello world");
  lcd.setCursor(0, 1);
  lcd.print("hello world");
  lcd.setCursor(0, 2);
  lcd.print("hello world");
  lcd.setCursor(0, 3);
  lcd.print("hello world");
 
}


floresta

Quote
Thanks for the reply, the issue is now ive made the changes i get the same error.

Assuming that the LCD still works when it is the only thing running then it is obvious that you still have some interaction between the various libraries.  Have you checked which pins the Ethernet library uses?

Don

Go Up