Hi everyone,
So my setup consists of an Arduino Uno with an Ethernet Shield connected to my desktop. They are communicating using over UDP. I have a Processing sketch that runs and sends strings.
I am just trying to get Serial monitor to print something when byte 0 is a 1 as shown below, but I’ve had no luck.
if (packetBuffer[0] == 1) {
Serial.println("HERE");
}
I think its a fairly obvious solution, but I can’t seem to find much documentation on it. I don’t know what to send over UDP. I thought if I sent the char ‘1’, it would trigger that if statement above, but I guess not.
Here is my current Processing sketch
import hypermedia.net.*;
UDP udp; // define the UDP object
void setup() {
udp = new UDP( this, 6000 ); // create a new datagram connection on port 6000
udp.log( true ); // <-- printout the connection activity
udp.listen( true ); // and wait for incoming message
}
void draw()
{
}
void keyPressed() {
String ip = "169.254.126.239"; // the remote IP address
int port = 8888; // the destination port
switch(key){
case '1':
udp.send("1", ip, port ); // the message to sen
break;
case '2':
udp.send("2", ip, port ); // the message to send
break;
case '3':
udp.send("3", ip, port ); // the message to send
break;
case '4':
udp.send("4", ip, port ); // the message to send
break;
case '5':
udp.send("5", ip, port ); // the message to send
break;
case '6':
udp.send("6", ip, port ); // the message to send
break;
}
}