GPS TRIGGER can use as a pin restriction
ej I want to pin restriction for one area and nobody can turn on the pin out to that area
If I understand your question, you want to limit someones ability to ādo somethingā, for example; activate a button, slider or switch (in the app) while the phone or tablet is in a specific area?
If so, then I belive you can use the GPS trigger, attached to a virtual pin, that then acts like a flag for another programmed function.
Perhaps like this:
BLYNK_WRITE(V0) // GPS Trigger
{
GPSflag = param.asInt(); // Set the flag to 1 or 0
}
BLYNK_WRITE(V1) // Button that does something if GPSflag is 1
{
if (GPSflag == 1) // Check flag
{
// Do something if flag is 1
}
else {
// Do something else and/or give feedback that something is not allowed in this location
}
}
@Jairo30 you could use the Terminal widget for users to enter a pin number and then include an if statement around every other Widget. If the pin is correct the Widget will run and if it isnāt no action will be taken.
thank for you replay but what I want to do is set a limit for a button, slider or switch (in the app) while the phone or tablet is in a specific area
what kind of limit?
a limit for a specific area with GPS TRIGGER
limit can you use the button just in specific area, like the garage door cannot open by mistake for a different location.
Hi, I am looking @ the same concept, Jairo30 have you got a solution
hello I been working in others project and I never take time to resolve this issue.
If you find more information please sharing with me this option is real good for security and void miss press buttons.
thank you
@Dalmine007 If you havenāt already, please take note of the timestamps when posting to older topics.
My first post already gave a solution to this āissueā; set a flag that gets set active only when the App is in a specific GPS determined area. Then with code, check that flag whenever the specified widget controls are activatedā¦ if flag active (in area), continue with action, if flag inactive (out of area) ignore command.
Basic Boolean Logic. https://www.arduino.cc/en/Reference/Boolean
Hi Sir, thanks for the help so far, I am having a small issue now. Getting the following error when uploading sketch
exit status 1
āGPSflagā was not declared in this scope
BLYNK_WRITE(V0) // GPS Trigger
{
GPSflag = param.asInt(); // Set the flag to 1 or 0
}
BLYNK_WRITE(V1) // Button that does something if GPSflag is 1
{
if (GPSflag == 1) // Check flag
{
// Do something if flag is 1
digitalWrite(13, high)
}
else {
// Do something else and/or give feedback that something is not allowed in this location
digitalWrite(13, low)
}
}
void setup()
Just as the error stated, you need to declare that variable, either globally or locally - scope - Arduino Reference
e.g. set GPSflag as a local integer.
int GPSflag = param.asInt(); // Set the flag to 1 or 0
@Dalmine007 as you are using the GPSflag in more than one function it will need to be declared as a global variable.
Thanks Guys itās working perfectly now
I am just posting final code as reference for anyone.
int GPSflag;
BLYNK_WRITE(V0) // GPS Trigger
{
GPSflag = param.asInt(); // Set the flag to 1 or 0
}
BLYNK_WRITE(V1) // Button that does something if GPSflag is 1
{
pinMode(13, OUTPUT);
if (GPSflag == 1) // Check flag
{
// Do something if flag is 1
// pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
delay(500);
digitalWrite(13, LOW);
}
else {
// Do something else and/or give feedback that something is not allowed in this location
digitalWrite(13, LOW);
}
}
void setup()
{
// Debug console
SwSerial.begin(9600);
// Blynk will work through Serial
// Do not read or write this serial manually in your sketch
Serial.begin(9600);
Blynk.begin(Serial, auth);
}
void loop()
{
Blynk.run();
}
Thanks for posting your code example for others as reference. However, Iād like to send a friendly reminder that itās also very helpful for other viewers if you format your code according to the guidelines on this page: [README] Welcome to Blynk Community! (you only have to tap the ` key 3 time before, and after, your pasted code snippet). So, please donāt take offense, and want to express my sincere thanks to everyone who participated in this thread, as Iām looking at adding some geo-location restrictions to my project behavior as well.
I fixed your formattingā¦ againā¦ please donāt post unformatted code double-oh or you might lose your license