UIPethernet myIP not changing

Hi. Can anyone tell me why the IP address in this code is not changing from the initial set default, to the IP address specified in the IF statement ?

I do need the IP addresses to be fixed, but want the code for 2 different units to be the same sketch, with the difference being the Ground on an input pin of the second unit.

// set these as the default IP address and MAC address

IPAddress myIP(192,168,1,115);     // IP address of unit 1 - DeviceType = 0
byte mac[] = { 0xDE, 0xAD, 0xEE, 0xBB, 0xAA, 0xED };

// test line to force DeviceType = 1 - usually a digitalread from an input pin
DeviceType = 1;

if(DeviceType == 1) {
    Serial.println("Device Type = Unit 2");
    IPAddress myIP(192,168,1,116);     // IP address of unit 2 - DeviceType = 1
    byte mac[] = { 0xDE, 0xAD, 0xEE, 0xBB, 0xBB, 0xED };

UIPEthernet.begin(mac, myIP, dnsServerIP, gateway, subnet); 
Serial.print("IP Address        : ");

The Serial Monitor does get the 'Device Type = Unit 2' so certain that the IF condition is met, but the :


always shows the initial IP address.


OK. Looks like I managed to solve this working from a different direction :

    IPAddress myIP1(192,168,1,115);
    byte mac1[] = { 0xDE, 0xAD, 0xEE, 0xFF, 0xAA, 0xED }; //physical mac address of the EN module
    IPAddress myIP2(192,168,1,116);
    byte mac2[] = { 0xDE, 0xAD, 0xEE, 0xBB, 0xBB, 0xED }; //physical mac address of the EN module

    if(DeviceType == 0) {
        UIPEthernet.begin(mac1, myIP1, dnsServerIP, gateway, subnet); 

    if(DeviceType == 1) {
        Serial.println("Device Type = Unit 2");
        UIPEthernet.begin(mac2, myIP2, dnsServerIP, gateway, subnet);