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

Virtual pins help


#1

Im trying to figure out how to make my LED widget on my phone come on
with virtual pin.
I have hardware tripping a relay,i have the relay going to my Arduino board with the 3.3 voltage from the Arduino board going through the relay,
trying to turn on my LED widget,not understanding where im supposed to send the power from my relay and what code i should be using.
I already have a blynk code im using for my alarm,i think i need this after my loop from what i am reading.
any help would be greatly appreciated


#2

LED widgets don’t need to be powered :stuck_out_tongue: they are just virtual LEDs on the App. As for example code…

https://examples.blynk.cc/?board=Arduino%20Uno&shield=ESP8266%20WiFi%20Shield&example=Widgets%2FLED%2FLED_Blink

https://examples.blynk.cc/?board=Arduino%20Uno&shield=ESP8266%20WiFi%20Shield&example=Widgets%2FLED%2FLED_Color

https://examples.blynk.cc/?board=Arduino%20Uno&shield=ESP8266%20WiFi%20Shield&example=Widgets%2FLED%2FLED_Fade

https://examples.blynk.cc/?board=Arduino%20Uno&shield=ESP8266%20WiFi%20Shield&example=Widgets%2FLED%2FLED_StatusOfButton

etc…

Well, we don’t see it :wink:


#3

Thanks for replying Gunner,im extremly green at this,its just a Blynk code basiclly,use to set my alarm and disable from fone,its just a token thats doing all the work i believe.
so how would i code my virtual LED outside the loop,im trying to send from PLC to relay to Arduino
to turn on LED widget to Blynk.


#4

I guess I don’t understand your question… All those examples show exactly how to trigger LED Widgets from code on the device side. If you already have some code (still invisible to use :wink: BTW ) that somehow picks up a signal from some PLC or relay, then by using a digitalRead(pin) command on a timer, you should be able to determine the pin state and thus trigger a Widget LED… much like that fourth link in my last post

https://www.arduino.cc/reference/en/language/functions/digital-io/digitalread/

We don’t write your code for you, we just try to help guide you through the learning process of Blynk.


#5

So here is my code,not asking you to write my code,just some guidence on how to make a virtual LED on Blynk to come on using output 3.3 volts from Arduino board to make the virtual led (v5) come on. So basiclly,how do i code an input to Arduino from my relay using the 3.3 volt from the Arduino board.what pins do i use for inputs from the relay.

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth);
  // You can also specify server.
  // For more options, see Boards_Ethernet/Arduino_Ethernet_Manual example
 , IPAddress(192,168,0,35), 8888);
}

void loop()
{
  Blynk.run();

}BLYNK_WRITE(V5) 

{  if (param.asInt() == 0) 
  {   
   digitalWrite(0, LOW); //HOME LIGHT ON PHONES
  } 
  else 
  {
  digitalWrite(255, HIGH); // HOME LIGHT ON PHONES
  }
}

#6

I had to format your posted code for you… please use the proper method as described in the Welcome Topic.

Meanwhile, Sorry dude… I still don’t see how/why you want to turn on a virtual LED from a physical relay.

I don’t think you understand enough yet to ask the right questions… or the understand answers already given.

For example, even your existing Arduino commands are messed up… So far, when pressing the button widget, you are alternately trying to turn OFF pin 0 (which on an Arduino is Serial RX) and turn ON pin 255… (which does not exist on any Arduino) :stuck_out_tongue:

Read through the Arduino side reference on how to properly use a digitalWrite() commands as others.

https://www.arduino.cc/reference/en/


#7

So after some searching,it turns out I can wire my mechanical relay being turned on by my PLC,using the voltage from my Arduino board to the digital pins on my board, changing them to inputs,assigning then to a virtual led.
So my next question,because I’m green to all this,is can I put it after the loop,or do I need to add to my project with my current token…any info be helpful,cause like I say I’m all green with this kind of logic.