ArduinoGeneral

Control devices over ethernet shield?

userHead amjlopez 2012-04-10 03:39:43 5331 Views3 Replies
I need to send UPD commands to a device connected to the ethernet shield. I am using UPDsendReceiveString code. But I don't find the way to include this parameters:

My device has IP 192.168.1.100 port (4352)
arduino IP 192.168.1.200

I want to send to the device this string "POWR 1" to switch ON/OFF
Can you help me please?

thank you very much
2012-04-11 18:47:09 Hi,


Actually at the end of the sample code there is a commented out section that explains how to do it.


Also, you could just define Udp.remoteIP, and Udp.remotePort manually.




[code]
// send a reply, to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
  delay(10);
}


/*
  Processing sketch to run with this example
=====================================================

// Processing UDP example to send and receive string data from Arduino
// press any key to send the "Hello Arduino" message


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      = "192.168.1.177"; // the remote IP address
int port        = 8888;        // the destination port

udp.send("Hello World", ip, port );  // the message to send

}

void receive( byte[] data ) {          // <-- default handler
//void receive( byte[] data, String ip, int port ) {  // <-- extended handler

for(int i=0; i < data.length; i++)
print(char(data[i])); 
println(); 
}
*/


[/code]
userHeadPic Hector
2012-04-11 01:09:07 Thank you very much for your response.
The code that I have was copied from Internet.
What I need is the following:

I have two Ethernet devices (Mitsubishi Projector).
Projector 1 has IP:192.168.1.10    port: 4352
Projector 2 has IP:192.168.1.11    port: 4352
Arduino IP:            192.168.1.12
I want to connect to an ethernet shield through a switch and send UDP commands to these devices.
Commands are very simple: "POWR 1"  to switch ON  and  "POWR 0"  to switch OFF. But I don't know how to send individually to each device.
Can you help me, please?

In the code that you sent me I don't  how to wrtie the IP for the remote device.
userHeadPic amjlopez
2012-04-10 18:42:38 Hi AmjLopez,


I made a quick search on google and found: [size=78%][url=http://arduino.cc/en/Tutorial/UDPSendReceiveString]http://arduino.cc/en/Tutorial/UDPSendReceiveString[/url][/size]


Let me know if this helps. Otherwise I think I need a little more details about your problem. Could you post the sample code and tell me what you have tried?
userHeadPic Hector