Dear users,
I’m proud to announce that I’ve develloped a new App for Android. This one just needs your particle cloud credentials and automaticly creates buttons for all your published functions of all your registered devices. If you publish “int” variables with the same name as your function and give them the value of 1 or 2, it will create a green or red text on the button accordingly. I’m also releasing one of my photons code for an example.
int buttonPin = A0;
int button2Pin = A1;
int ledPin = D0;
int lichtPin = D2;
int relay1 = D1;
int lichtaan = 1;
bool laststate = false;
int poortopen = 1;
void setup() {
pinMode( buttonPin , INPUT_PULLUP);
pinMode( button2Pin , INPUT_PULLUP);
pinMode( ledPin , OUTPUT );
pinMode( lichtPin , OUTPUT );
pinMode( relay1 , OUTPUT );
RGB.control(true);
RGB.color(0, 0, 0);
Particle.function("LichtGarage", switchLicht);
Particle.function("PoortGarage", switchrelay1);
Particle.variable("LichtGarage", lichtaan);
Particle.variable("PoortGarage", poortopen);
}
void loop()
{
int buttonState = digitalRead( buttonPin );
int buttonState2 = digitalRead( button2Pin );
if ( buttonState == LOW )
{
poortopen = 2;
digitalWrite( ledPin, HIGH);
} else {
poortopen = 1;
digitalWrite( ledPin, LOW);
}
if ( buttonState2 == LOW )
{
if (laststate) {
switchLicht("");
}
laststate = false;
} else {
if (laststate == false) {
switchLicht("");
}
laststate = true;
}
if ( lichtaan == 2 )
{
digitalWrite( lichtPin, HIGH);
} else {
digitalWrite( lichtPin, LOW);
}
}
int switchLicht(String dada) {
if (lichtaan == 2) {
lichtaan = 1;
} else {
lichtaan = 2;
}
}
int switchrelay1(String dada) {
digitalWrite(relay1, HIGH);
delay(500);
digitalWrite(relay1, LOW);
return 1;
}
My Garage has 2 normal switches for the light wich I reconnected to the photon and then seperatly connect the lights to a relay connected to the photon. My garagedoor has a normal mechanical “push” sensor which activates as soon the door opens. When the door is open a flash light connected to another relay starts blimping…
The app itself can be found on the playstore, hope it can be of help to some of you…
Greetings,
Vibrocil