Hi All,
first time project here I have got a loop running which will switch on and off a pump via a transistor. So Far So Good.
Then I thought I would like to get my Alexa to switch it on or off rather than using a timer. I am using a nano 33 IOT
I configured a couple of variables pump and drink that I can switch on and off via Alexa.
BUT
The on change functions do not seem to get called when I change them. All I am trying to do at the mo is to write a message to the serial monitor when they change so I can see how it works but it is not triggering
Code is below
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/3169c6fa-c0bb-4121-9869-2c0331cdf095
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
CloudSwitch drink;
CloudSwitch pump;
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
which are called when their values are changed from the Dashboard.
These functions are generated with the Thing and added at the end of this sketch.
*/
#include "thingProperties.h"
#define ASWITCH 4
bool PumpStatus = false;
bool DrinkStatus = false;
int i;
void setup() {
//---set pin direction
pinMode(ASWITCH,OUTPUT);
Serial.begin(9600);
}
void loop() {
Serial.println(PumpStatus);
digitalWrite(ASWITCH, PumpStatus);
Serial.println("ASWITCH IS");
Serial.println(PumpStatus);
delay(10000);
PumpStatus = HIGH;
digitalWrite(ASWITCH, PumpStatus);
Serial.println("ASWITCH IS");
Serial.println(PumpStatus);
delay(10000);
PumpStatus = LOW;
Serial.println("Drink is ");
Serial.println(drink);
Serial.println("EndLoop");
}
void onPumpChange() {
// Do something
Serial.println("Isla is the best!");
Serial.println(pump);
//PumpStatus = pump;
}
void onDrinkChange() {
// Do something
Serial.println(drink);
//DrinkStatus = drink;
Serial.println("Jim");
}
ANy Pointers would be apreciated
thanks
James