We are trying to get Particle to send a variable value in return when its LED at D7 is turned on with a switch. The code is sending the variable type instead of the variable value to the Cloud. I want to use this variable value as a trigger in IFTTT and get a notification sent to my mobile. How do I get the variable value instead of type?
Code:
// -----------------------------------------
// Function and Variable with buttonInputs
// -----------------------------------------
// port led
int led = D7;
int buttonInput = D2; // This is where your buttonInput is plugged in. The other side goes to the "power" pin (below).
int buttonValue; // Here we are declaring the integer variable analogvalue, which we will use later to store the value of the buttonInput.
// Next we go into the setup function.
void setup() {
// D7
pinMode(led,OUTPUT);
pinMode(buttonInput,INPUT_PULLUP);
// pinMode(power,OUTPUT);
// turn off led
digitalWrite(led,LOW);
// We are going to declare a Particle.variable() here so that we can access the value of the buttonInput from the cloud.
Particle.variable("buttonValue", &buttonValue, INT);
}
// Next is the loop function...
void loop() {
if ( digitalRead(buttonInput) == LOW ) { // check if the input is HIGH (button released)
digitalWrite(led, HIGH); // turn LED ON
} else {
digitalWrite(led, LOW); // turn LED OFF
}
delay(100);
// check to see what the value of the buttonInput is and store it in the int variable analogvalue
// buttonPushedValue = analogRead(buttonInput);
buttonValue = analogRead(buttonInput);
}