BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Arduiono - Will automated system run when Mobile App is down?

I tried to make a simple test using Aduino Uno, a USB serial cable and Blynk. Worked ok.

But then I also tried to set ut a blinking diode locally controlled by Arduino. Did not work.

When I commented out all program code that referes to Blynk, then the blinks worked.

I found a discussion tread. The programming of these physical buttons is not like “it use to be” it looks more like input to Blynk.

Does Blynk work in such a way that it overrides all ordinary Arduino local control? Does that mean that an automated system based on Arduino/Blynk wil stopp working if you switch of your mobile phone?

(If this should be the case it should be possible to solve the problem using two Arduinos, one for “local control” and one for “managed by Blynk”.)

I have no idea why you think that this topic has a similarity to what you’ve vaguely described earlier, or what the “not like it used to be” comment relates to.

No.

No, assuming that you aren’t using Bluetooth connectivity.

Pete.

1 Like

Thanks for feedback. I am a new beginner with Blynk and I try to learn.

I think I first tried to control the same input pins wth physical buttons and Blynk and that this did not work. I then treid to control two different output pins with local buttons and with Blynk. This worked.

By the way it is my first impression that Blynk is a very good and profesional software, that makes it quite easy to get started with IoT.

My advice would be to exclusively use Virtual pins in the App.

Pete.

Yes I did, and now it works exactly as I want it to work. But one question:

Is this program-code made “the proper way”, or should it be “improved” or changed in any way to be “as recomended”? I only have a Uno with USB serial cable for testing.

Output pin 10 should be “started” or stopped locally from pin 2 and 3 and also remotely from Blynk, so that you can have a local control and a remote control that is both working independently.


#include <BlynkSimpleStream.h>

char auth[] = "xxxxxxxxxxxxx";

void setup()
{
  
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(10, OUTPUT);

  Serial.begin(9600);
  Blynk.begin(Serial, auth);

}

int rstart;
BLYNK_WRITE(V1)
{
  rstart = param.asInt(); 
}

int rstop;
BLYNK_WRITE(V2)
{
  rstop = param.asInt(); 
}

void loop()
{

Blynk.run();

if (digitalRead(2) || rstart){digitalWrite(10,1);}

if (digitalRead(3) || rstop){digitalWrite(10,0); }

if (digitalRead(10)){Blynk.virtualWrite(V3, 255);}

if (!digitalRead(10)){Blynk.virtualWrite(V3, 0);}

delay(20);

} 

Best reg Arne

@arne22 please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```

Pete.

Done, I hope :slight_smile:

No, it is not.

Yes, your void loop needs to be cleaned-up and the physical switches read using a timer.
Read this:

I’d also take a look at the “sync physical button” example in the sketch builder - it’s a ready made example for one switch/switch widget and LED.

Also, I’d recommend either switching your LEDs in the BLYNK_WRITE callbacks, or if you want to streamline your code, calling a function from those callbacks to switch the LEDs and call the same function when the physical switches change state.

Pete.

Thanks for feedback. I will give it a new try.

Thank you very much for your help and telling me I was wrong. I have now used the example programs and removed everything from the loop and I belive it works good now :slight_smile: