Estoy probando hacerlo por medio de UDP, pero me gustaria hacerlo por medio de TCP-IP para poder confirmar que el envio fue hecho correctamente, aunque talvez lo pueda hacer por udp, haciendo que arduino espere una respuesta del programa hecho en delphi.
Aqui les paso el codigo con el cual estoy haciendo las pruebas, por si alguno tiene alguna experiencia con este asunto:
delphi
/* UDPSendReceive.pde: This sketch receives UDP message strings, prints them to the serial port and sends an "acknowledge" string back to the sender A Processing sketch is included at the end of file that can be used to send and received messages for testing with a computer. created 21 Aug 2010 by Michael Margolis This code is in the public domain. */ #include <SPI.h> // needed for Arduino versions later than 0018 #include <Ethernet.h> #include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008 // 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, 69, 200); //IPAddress remip(10, 0, 0, 2); unsigned int localPort = 5015; // local port to listen on int pulsador=7; //antes era el 40 int valor=(digitalRead(pulsador)); //int rport =5000; // buffers for receiving and sending data char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet, char ReplyBuffer[] = "acknowledged"; // a string to send back // 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); // Udp.remoteIP=(remip); // Udp.remotePort(rport); Serial.begin(9600); pinMode(pulsador,INPUT); } void loop() { if (digitalRead(pulsador)==LOW) { IPAddress destinationIP(10,0,0,2); // Address of target machine unsigned int destinationPort = 5000; // Port to send to Udp.beginPacket(destinationIP, destinationPort); if (digitalRead(pulsador) == HIGH) { Udp.write("ON"); } else { Udp.write("OFF"); } Udp.endPacket(); } }