Pages: [1]   Go Down
Author Topic: LCD not working after UDP is initiated.  (Read 926 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

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:
#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:
#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.



* WP_20130213_001[1].jpg (1576.58 KB, 3264x2448 - viewed 23 times.)

* WP_20130213_002[1].jpg (1609.53 KB, 3264x2448 - viewed 21 times.)
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4394
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

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

Code:
#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");
 
}

Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 4394
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: [1]   Go Up
Jump to: