[SOLVED] Send variable from Ubidots slider to arduino

I have a slider set up in the dashboard and I can connect it to the arduino and can see the variable in the serial monitor. The change is happening by the change I notice in the monitor but using the client.getValue command I do not get the value extracted. I have the slider set up with a min of 0 and max of 100 and step of 25. the value I get out of the client.getValue is always 25 even though I see it change to the 4 different steps in the monitor.

Thanks

Hi @usdharris we’ll check the example; can you please specify which Arduino library are you using? we have several libraries…

@usdharris paste here your code please.

Best regards,
Metavix

Here is my code.

#include <Ethernet.h>
#include <SPI.h>
#include <UbidotsEthernet.h>
#define ID_power  "5787a1c37625424eaeb5ffbd"  // Put here your Ubidots variable ID
#define TOKEN  "TOKEN123"  // Put here your Ubidots TOKEN


// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 0, 177);

int plevel;

Ubidots client(TOKEN);

void setup(){
    Serial.begin(9600);
    // start the Ethernet connection:
    if (Ethernet.begin(mac) == 0) {
      Serial.println("Failed to configure Ethernet using DHCP");
      // try to congifure using IP address instead of DHCP:
      Ethernet.begin(mac, ip);
    }
    // give the Ethernet shield a second to initialize:
    delay(1000);
    
}
void loop(){

plevel = client.getValue(ID_power);

if (plevel = 0) {
  digitalWrite(8, LOW);
}
else if ( plevel = 25){
  digitalWrite(5, HIGH);
}
else if (plevel = 50){
  digitalWrite(6, HIGH);
}
else if (plevel >= 75){
  digitalWrite(7, HIGH);
  }


Serial.println(plevel);

delay (3000);

}

I just realized my error.

In my else statements I had plevel = instead if plevel ==

Obviously setting the variable instead of comparing it.

Thus shows my newness to programming. Thanks

@usdharris Great!
I’m happy to read that. If you have another problem we will be here for you.

Best regards,
Metavix