#include <EtherCard.h>
static unsigned int CSPIN_ENC28J60 = 53;
byte macMy[] = {0x00, 0x22, 0xF9, 0x01, 0x30, 0xDA }; //MAC vom Arduino
byte ipMy[] = {192, 168, 2, 200}; //
IP vom Arduino
byte ipDestination[] = {192, 168, 2, 99}; //Ziel
Ip Des Paketes
byte ipGateway[] = {192, 168, 2, 1}; //Router
IP
const int portPcEmpfangen = 50001;
byte Ethernet::buffer[1000];
char msg[] = {"Hello World"};
void setup() {
ether.begin(sizeof Ethernet::buffer, macMy, CSPIN_ENC28J60);
ether.staticSetup(ipMy, ipGateway);
while (ether.clientWaitingGw())
{
ether.packetLoop(ether.packetReceive());
}
}
void loop()
{
ether.sendUdp(msg, sizeof msg, portPcEmpfangen, ipDestination, portPcEmpfangen);
word len = ether.packetReceive(); // go receive new packets
word pos = ether.packetLoop(len); // respond to incoming pings
ether.packetLoop(ether.packetReceive());
delay(1000);
}