The frustrating thing is, you read other post (thousands) about the simple topic of using a virtual pin just to show the LED status of a digital or analog pin. Millions of examples !!! I can’t get one to work.
Do you load WidgetLED? What’s with the led1? Is that a generic reference meaning substitute the GPIO pin #? Do you load it within the Void Setup() or after? Are you supposed to put something after Void Loop() so it knows to keep your LED up to date? … I read that somewhere. If you load it in Void Setup() won’t it run once then go stale?
I read that someone was making a guide on Github for GetData, read that, didn’t cure my defective code.
I’m a Dad, four kids, they all drive. I just want to know if the Garage Door is closed or open, when did it open or close, with a history log. Glance at my phone to see the “Clsd” or “Open” LEDs glow.
I know this is vhymanskyy’s most loathed topic YAGDO. If someone could peak into my super simple, cobbled together code and and throw me a bone I’d be grateful. I’ve got two Hall Sensors that work great. They light up an RBG (Red, Green) LED on my Breadboard (D2,D3) so I know what’s working on what’s not. The relay’s, simple as they are work great through Blynk. I’d rather key off the Hall GPIOs on the Analog side A3, A4 to free up the two digital pins once it’s mounted in the garage. I’ll take whatever works.
Thanks in advance !!!
// This #include statement was automatically added by the Particle IDE.
#include "blynk/blynk.h"
//
char auth[] = "b2784b3b3c594???????8752709100fd";
// Double Door Reed Swith CLOSED
// ******************************
const int closedreedswitch = A4;
const int closedled = 2;
int hallstateclosed = 0;
//*******************************
//
// Double Door Reed Swith OPEN
// ******************************
const int openreedswitch = A3;
const int openled = 3;
int hallstateopen = 0;
void setup ()
{
Serial.begin(9600);
Blynk.begin(auth);
pinMode( 0 , OUTPUT); // Whole House Fan #1 Motor 4amp
pinMode( 1 , OUTPUT); // Whole House Fan #2 Motor 4amp
pinMode(closedreedswitch, INPUT);
pinMode(closedled, OUTPUT);
// OPEN Reed Setup
pinMode(openreedswitch, INPUT);
pinMode(openled, OUTPUT);
pinMode( 6 , OUTPUT); // Door One on Digital Pin D7
pinMode( 4 , OUTPUT); // LED Indicator Light on Digital Pin D6
pinMode( 7 , OUTPUT); // Door Two on Digital Pin D5
// The next two lines shutdown the relay so when the power bumps your doors don't pop open.
digitalWrite( 7 , LOW ); //Double Garage Door Switch
digitalWrite( 6 , LOW ); //Single Garage Door Switch
digitalWrite( 0 , HIGH ); //Whole House Fan #1
digitalWrite( 1 , HIGH ); //Whole House Fan #2
delay( 1000 );
digitalWrite( 4 , LOW ); // This is the LED indicating the program has started.
delay( 450 );
digitalWrite( 4 , HIGH );
delay( 250 );
digitalWrite( 4 , LOW );
delay( 250 );
digitalWrite( 4 , HIGH );
delay( 250 );
digitalWrite( 4 , LOW );
delay( 250 );
digitalWrite( 4 , HIGH );
delay( 250 );
digitalWrite( 4 , LOW );
delay( 250 );
digitalWrite( 4 , HIGH );
delay( 250 );
digitalWrite( 4 , LOW );
delay ( 250 );
digitalWrite( 4 , HIGH);
delay ( 250 );
digitalWrite( 4 , LOW);
}
// ---------[ Widget Button using virtual pin # 0 ]--------------------
BLYNK_WRITE(V0)
{
if (param.asInt() == 0)
{
digitalWrite(2, LOW); //GPIO2
}
else
{
digitalWrite(2, HIGH); // GPIO2
}
}
void loop()
{
Blynk.run();
// CLOSED Reed Part of Loop
hallstateclosed = digitalRead(closedreedswitch);
if (hallstateclosed == LOW){
digitalWrite(closedled, HIGH);
}
else{
digitalWrite(closedled, LOW);
/// OPEN Reed Part of Loop
hallstateopen = digitalRead(openreedswitch);
if (hallstateopen == LOW){
digitalWrite(openled, HIGH);
}
else{
digitalWrite(openled, LOW);
}}}