Hi,
I'm having a problem with the ethernet library. I'm building a device that sends UDP packets every time a button is pressed. But when I start the ethernet library my code doesn't execute like it should.
Here's a slimmed down version of the code
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 2, 9, 200, 175 }; // ip adres arduino
unsigned int localPort = 52193; // local port to listen o
IPAddress destinationIP =(2,9,200,176); // ipadress chamsys
unsigned int destinationPort = 6553; // poort van chamsys
EthernetUDP Udp;
void setup()
{
Ethernet.begin(mac, ip); //When this is included, the commands aren't executed in the right way (1,24,36) ...
Udp.begin(localPort);
Serial.begin(9600);
Serial.println("thunderbirds are go !!");
}
void loop()
{
if(digitalRead(47) == HIGH && digitalRead(30) == HIGH){sendCommand("0G");}
if(digitalRead(47) == HIGH && digitalRead(32) == HIGH){sendCommand("1G");}
if(digitalRead(47) == HIGH && digitalRead(34) == HIGH){sendCommand("2G");}
if(digitalRead(47) == HIGH && digitalRead(36) == HIGH){sendCommand("3G");}
if(digitalRead(47) == HIGH && digitalRead(38) == HIGH){sendCommand("4G");}
if(digitalRead(47) == HIGH && digitalRead(40) == HIGH){sendCommand("5G");}
if(digitalRead(47) == HIGH && digitalRead(42) == HIGH){sendCommand("6G");}
if(digitalRead(47) == HIGH && digitalRead(44) == HIGH){sendCommand("7G");}
if(digitalRead(47) == HIGH && digitalRead(46) == HIGH){sendCommand("8G");}
//...
if(digitalRead(22) == HIGH && digitalRead(52) == HIGH){sendCommand("95G");}
}
void sendCommand(char *command)
{
Serial.println();
Serial.print(command);
Serial.print(" is send");
Serial.println();
//send UDP packet ...
}
When I press the first button I get this output
But when I comment out Ethernet.begin I get this output.
Can someone please explain me what's the cause of this (and a possible solution?)
The board is an Arduino Mega2560 with a R3 Ethernet shield
Thanks in advance ![]()
Dieter