Hello,
I want to write a Blynk app using a Particle Photon. I’m new to Blynk and I need help with getting a virtual LED to go on when a virtual button is pressed.
My Blynk app consists of 2 Virtual buttons, fan and led (V0 and V1 respectively) and on the Photon, D6 and D7 respectively . It also has 2 virtual LED’s, led1 and led2 (V4 and V3 respectively). My objective is that when Virtual button V0 is pressed, the following happens, it turns on small fan connected to pin D6 on the Photon, via a transistor and the Virtual LED , led1, turns on. Same when Virtual button V1 is pressed, the Photon on board LED turns on (D7) and Virual LED led2 turns on. When I flash the photon with my code, the an turns on and the Photon on board LED turns on but none of the virtual LED’s.
I have tried to get my code to do so but in vain. Following is the code , can anyone help?
// This #include statement was automatically added by the Particle IDE. #include “blynk/blynk.h”
char auth[] = “My authorisation code”;
int fan = D6;
int led = D7;
bool buttonStatus;
WidgetLED led1(V4);
WidgetLED led2(V3);
thank you for your suggestion.
I changed the code as follows and still having the same problem. What am I doing wrong?
// This #include statement was automatically added by the Particle IDE. #include “blynk/blynk.h”
char auth[] = “16efab0214aa484d84d40e48ffb453f8”;
int fan = D6;
int led = D7;
int buttonStatusfan;
int buttonStatusled;
WidgetLED led1(V4);
WidgetLED led2(V3);
int virtualbuttonclosed = param.asInt();
if (virtualbuttonclosed == 1)
// if (V0 == 1)
{
digitalWrite(led,HIGH);
Blynk.virtualWrite(V3,255);
Blynk.virtualWrite(V5,"LED ON ");
}
else
{
digitalWrite(led,LOW);
Blynk.virtualWrite(V3,0);
Blynk.virtualWrite(V5,"LED OFF ");
}
Hi Enzo.
I am using your example.
Could you clarify what you are doing with A0 and D3.
Another question I have is: how do I use the LCD widget on Blynk. Did you set it up as Simple or Advanced? Virtual pin V2 and V5? Did you use 2 LCD widgets?