I've tried this but it still gives errors. The code i've used you can see below
The errors:
Test_Chamsys_Ethernet.cpp:23:54: error: too many decimal points in number
Test_Chamsys_Ethernet.cpp:43:34: error: too many decimal points in number
Test_Chamsys_Ethernet.cpp: In function 'void sendPacket(char*)':
Test_Chamsys_Ethernet:38: error: no matching function for call to 'EthernetUDP::remotePort(int)'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ethernet/EthernetUdp.h:96: note: candidates are: virtual uint16_t EthernetUDP::remotePort()
#include <SPI.h>
#include <Ethernet.h>
#include <EthernetUdp.h>
// 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, 1);
unsigned int localPort = 8080; // local port to listen on
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup()
{
Ethernet.begin(0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED, 192.168.1.1); //Start the Ethernet and UDP
Udp.begin(8080);
pinMode(22, INPUT); // Sets the digital pin as input
pinMode(23, INPUT); // Sets the digital pin as input
pinMode(24, INPUT); // Sets the digital pin as input
pinMode(25, INPUT); // Sets the digital pin as input
}
void loop()
{
if (digitalRead(22) && digitalRead(23))
sendPacket("g1");
if (digitalRead(24) && digitalRead(25))
sendPacket("g2");
}
void sendPacket(char *contents)
{
Udp.beginPacket(Udp.remoteIP(192.168.1.10), Udp.remotePort(8080));
Udp.write(contents);
Udp.endPacket();
}
Thanks
Leon