#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[] = {
0x90, 0xA2, 0xDA, 0x0D, 0x0C, 0xE9 };
IPAddress ip(195, 100, 101, 61);
unsigned int localPort = 8888; // local port to listen on
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac,ip);
Udp.begin(localPort);
}
void loop() {
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write("hello");
Udp.endPacket();
}
this is the sketch uploaded on arduino ethernet shield.
i'm trying to receive these packets on my laptop powering this shield.
using processing
import hypermedia.net.*;
int PORT_RX=3000; //port
String HOST_IP="195.100.101.60"; //
UDP udp;
string receivedFromUDP = "";
void setup() {
size(400,400);
udp= new UDP(this,PORT_RX,HOST_IP);
udp.log(true);
udp.listen(true);
super.start();
}
void draw() {
background(0);
text(receivedFromUDP, 50, 50);
}
void receive(byte[] data, String HOST_IP, int PORT_RX) {
receivedFromUDP ="";
for (int i = 0; i < data.length; i++) {
receivedFromUDP += str(data*) + " ";*
- }*
- println(data);*
- }*
its shows nothing...
no output , where changing the global variable at declaration itself , changes the output in the output window
plz help.
also how to find out input port for receiving ..... netstat -an ????