How can i connect my float switch to cayenne. heres my code:
int FloatSwitchState = 0; // current state of the FloatSwitch
int lastFloatSwitchState = 0; // previous state of the FloatSwitch
void setup() {
// initialize the FloatSwitch pin as a input:
pinMode(FloatSwitchPin, INPUT);
// initialize serial communication:
Serial.begin(9600);
}
void loop() {
// read the pushFloatSwitch input pin:
FloatSwitchState = digitalRead(FloatSwitchPin);
// compare the FloatSwitchState to its previous state
if (FloatSwitchState != lastFloatSwitchState) {
// if the state has changed do the following:
Serial.print("State Changed! The pin is: "); // Text output to the Serial Monitor
Serial.println(FloatSwitchState); // Print out the pin's digital state to the Serial Monitor
// save the current state as the last state,
//for next time through the loop
lastFloatSwitchState = FloatSwitchState;
}
}
thank you in advanced