Hi,
We had a project a while back where we needed two arduinos to be able to communicate over ethernet via a network switch (not a router). It is just Arduino - switch - fibre link - switch - Arduino.
We decided to hire someone to add the thernet side of things to our working code. We had a code that did what we needed to on one Arduino. Read in pots/switches/joysticks, and then output PWM. We just needed the joysticks on one end of the link and pwm output at the other Arduino.
The person we hired has only made it work via a router, and not as requested via a switch. And don't seem to know how to fix it.
Im hoping somebody could have a look at the two sketches attached. Which work if there is a router in the arrangement, but don't if only via a switch.
Ground end (switchs/pots etc)
#include <Adafruit_GFX.h>
#include <UIPEthernet.h>
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x06,0x05};
EthernetClient client;
signed long next;
int flag=0 , flag1=0;
#include "Adafruit_ST7735.h"
#include <SPI.h>
int Arry_to_send[11]={0};
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
#define TFT_SCLK 13
#define TFT_MOSI 11
int focusPin = A4;
int zoomPin = A3;
int tiltPin = A2;
int panPin = A1;
int focusspeedPin = A6;
int zoomspeedPin = A7;
int tiltspeedPin = A8;
int panspeedPin = A5;
// Digital Pins, more will be added
int modeLockPin = 21;
int modeTrackPin = 22;
int modeCutPin = 23;
int linkledPin = 24;
int contledPin = 25;
int gimledPin = 26;
int focusVal = 0;
int zoomVal = 0;
int tiltVal = 0;
int panVal = 0;
int focusspeedVal = 0;
int zoomspeedVal = 0;
int tiltspeedVal = 0;
int panspeedVal = 0;
int modeLockVal = 0;
int modeTrackVal = 0;
int modeCutVal = 0;
String focusVal_s ="";
void setup() {
Serial.begin(9600);
pinMode(modeLockPin, INPUT);
pinMode(modeTrackPin, INPUT);
pinMode(modeCutPin, INPUT);
Ethernet.begin(mac);
Serial.println(Ethernet.dnsServerIP());
}
void loop()
{
if (((signed long)(millis() - next)) > 0)
{
next = millis() + 5000;
Serial.println("Client Try connect");
if (client.connect(IPAddress(192,168,1,6),1000))
{
Serial.println("Client connected ");
while(1)
{
if (client.connect(IPAddress(192,168,1,6),1000))
{
sensors.requestTemperatures();
focusVal = analogRead(focusPin);
zoomVal = analogRead(zoomPin);
tiltVal = analogRead(tiltPin);
panVal = analogRead(panPin);
focusspeedVal = analogRead(focusspeedPin);
zoomspeedVal = analogRead(zoomspeedPin);
tiltspeedVal = analogRead(tiltspeedPin);
panspeedVal = analogRead(panspeedPin);
modeLockVal = digitalRead(modeLockPin); //need these values in the air end
modeTrackVal = digitalRead(modeTrackPin);
modeCutVal = digitalRead(modeCutPin);
Arry_to_send[0]=focusVal;
Arry_to_send[1]=zoomVal;
Arry_to_send[2]=tiltVal;
Arry_to_send[3]=panVal;
Arry_to_send[4]=focusspeedVal;
Arry_to_send[5]=zoomspeedVal;
Arry_to_send[6]=tiltspeedVal;
Arry_to_send[7]=panspeedVal;
//Arry_to_send[8]=modeLockVal;
//Arry_to_send[9]=modeTrackVal;
//Arry_to_send[10]=modeCutVal;
for( int x=0 ; x<8 ;x++)
{
client.print(Arry_to_send[x]);
client.print("\n");
Serial.println(Arry_to_send[x]);
}
Serial.println("------------------- new-----------------");
}
}
}
}
}