我正在尝试利用Google Assistant命令通过IFTTT和粒子云在Raspberry pi上触发GPIO4。
我已验证:
这是我的粒子云代码,谁能告诉我我要去哪里错了?
(注D0
可能是GPIO4的粒子云参考)
int relay = D0; //pin to which relay is connected
int boardLed = D7;
bool vin = LOW; //a virtual boolean variable
// setup() is run only once, it's where we set up GPIO and initialise peripherals
void setup() {
// Setup GPIO
pinMode(relay,OUTPUT); // relay pin is set as output
digitalWrite(relay,HIGH);
// Subscribe to events published by IFTTT using Particle.subscribe
Particle.subscribe("welcome_mode_off", myHandler); //turning off function declaration
Particle.subscribe("welcome_mode_pn", thisHandler); //turning on function declaration
}
// loop() runs continuously, it's our infinite loop.
void loop() {
if (vin==HIGH)
{
digitalWrite(relay,LOW);
}
else if (vin==LOW)
{
digitalWrite(relay,HIGH);
}
}
//our events are called when IFTTT applets are triggered
void myHandler(const char *event, const char *data)
{
vin=LOW;
}
void thisHandler(const char *event, const char *data)
{
vin=HIGH;
}