Hey, I’m trying to turn on led if button is pushed with trigger. For some reason the trigger just won’t work. I can see online that button is pushed but the LED won’t turn on. Trigger which turns on one led on if other one is on is working okay though. I have no idea why it doesn’ work. Posting code.
#include <CayenneMQTTESP8266.h>
#include <DHT.h>
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
char ssid[] = "fsfsfsfsfs";
char password[] = "Tgdgdgdg";
char username[]="gotta";
char mqtt_password[] = "be careful";
char client_id[] = "next time";
int buttonstate;
void setup() {
// put your setup code here, to run once:
Cayenne.begin(username,mqtt_password,client_id,ssid,password);
pinMode(D6, OUTPUT);
digitalWrite(D6, HIGH);
pinMode(D5, OUTPUT);
digitalWrite(D5, HIGH);
pinMode(D7, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int buttonstate = digitalRead(D7);
Cayenne.loop();
if(buttonstate == HIGH) {
Cayenne.virtualWrite(2, HIGH);
}else {
Cayenne.virtualWrite(2, LOW);
}
}
CAYENNE_IN(0)
{
digitalWrite(D6, getValue.asInt());
}
CAYENNE_IN(1)
{
digitalWrite(D5, getValue.asInt());
}