Wondering if I could get some advice on this issue. I am trying to use the DAC1 Analog output to send a voltage based on a variable I read from Ubidots. I have confirmed that the value is ok from the dashboard, and have made sure to use an int data type. I have tested using a numeral on the analog write command (4095) and it works fine. I only have the issue when I am trying to use a variable value:
void loop() {
int value1 = analogRead(A0);
int value2 = analogRead(A1);
int value3 = analogRead(A2);
int Analog3 = ubidots.getValue(VAR_ID);
// analogWrite(A3, 4095); Works fine.
analogWrite(A3, Analog3);
ubidots.add("A0", value1); // Change for your variable name
ubidots.add("A1", value2);
ubidots.add("A2", Analog3);
ubidots.sendAll();
//if(Analog3!=NULL){
//Serial.println(Analog3);
//}
delay(5000);
I am using the 0.6.3 firmware. The sample code you gave me worked. It steps up in brightness. Had to fix the increment line. value4=value4+100;
I then changed the code to the variable I am reading from Ubidots, and update via the Serial.printlnf(“value4=%d”, value4); line you have above, and it works! Any explanation for this?
I see the difference. I tried to create an int from the ubidots.getValue command, ie int value1=ubidots.getValue(VAR_ID), by you scaling it on the particle side and converting to an int, it insures the proper datatype and the proper value. I will modify my code to do it this way.
@vtrufus, I did not realise that ubidots.getValue() returns a float… that explains everything. We should have asked the question “What type does ubidots.getValue() return?” right at the start…