Basic physical LED Control via Blynk

Your code seems OK and you are getting the serial prints, so the issue must be your wiring to the LED. Comfirm you have it the correct way around ( long lead to +) between D1 (Arduino 5) and short lead to either GND or 3.3v… Depending on how you want to use the digital pin, as source or sink respectively.

For testing, you can also use D4 (Arduino 2) without any wiring as that pin is connected to the internal LED.

No success, I do not know why but now the led light usually. It lie usually against 2,45V which I meassured with an multimeter, equal if I push the button in the app or not. The same happens with my other Wemos D1 mini. If I connect the LED with ground and D4 it shines because on the output I usually measure 2,45V

Try this

Nothing…no internal led light
:sob::sob::sob:

Look here and try that non-blynk LED flashing code…

It’s not working because

  pinMode(5, OUTPUT);          // sets the digital pin 5 as output

is missing from void setup()

Pete.

Good catch!! That’s one reason I “normally” stay away form forum use on the phone… too easy to miss little details on little screen :stuck_out_tongue:

1 Like

Crazy man, now the led is blinking, which means: yes it works, but what more? :thinking:
Now I tried both version: First with the pin declaration 2 and after with D4. By both versions the led blinks

//Version 1
void setup() 
{
 pinMode(D4, OUTPUT); 
}

void loop()
{
digitalWrite(D4, LOW); 
  delay(500);
 digitalWrite(D4, HIGH); 
 delay(500);
}



//Version 2
//void setup() 
//{
// pinMode(2, OUTPUT); 
//}
//
//void loop()
//{
//digitalWrite(2, LOW); 
//  delay(500);
// digitalWrite(2, HIGH); 
// delay(500);
//}

Now I understand that it is equal if I write 2 or D4…its the same, but how it helps me on. With Blynk do not work
:laughing: :laughing:
In the meantime thanks for your patience :point_right::+1:

Now add that pinMode() command, that @PeteKnight noticed is missing from your original sketch… then you should be good.

for example

void setup()
{
  pinMode(5, OUTPUT); 
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
}

Both versions will work with Blynk, but it’s not good programming practice to use the D numbers rather that GPIO numbers because it makes it much more difficult to transfer yoir code from one device to another.
The D references won’t work with an Arduino, or possibly with future boards, whereas directly referencing the GPIO pins will work on any platform.

Pete.

@PeteKnight After a year+ of hearing someone :thinking::stuck_out_tongue_winking_eye: gripe about “stupid silk screening” I find out that it was intentional on Wemo’s part… probably part of their D1 board nomenclature.

Now that I know, I actually use the Dpin labeling for Wemos code. I think it is a good idea since I constantly use both types of boards, and now know at a glance if my sketch pin-outs are correct, instead of always dragging out my little black binder of board pin-outs :face_with_monocle:

Foolish, why didn’t they just put the correct GPIO numbers.

Even though D references work when compiling as WeMos that doesn’t really fix the issue.
You need the real GPIO’s when you start using Blynk’s API etc and when you compile as a generic ESP8266 for the additional debugging.

I would still well clear of the WeMos and NodeMCU labelling of pins.

Marketing most likely.

Yes, but I also still use Arduino and ESP-01… born to be a lone wolf I guess ::smiley:

@Hannes.P Sorry, this side discussion is probably best in that other semi related topic. Meanwhile, stick with proper Arduino pin designation and let us know if you got your code working with pinMode()

Yeah men, thanks! You are the best!
First step, switch on an off a LED works now, lets go on, there is still much more potential in Blynk. :star_struck::star_struck::star_struck:
If someone need in future a sketch to switch something which is hardware interrupt with a microcotroller, here is a sketch which works (used with a Wemos D1 mini):

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "b5a2426a237549448f9dff83xxxxxxxx"
char ssid[] = "Fritzboxxxxx";
char pass[] = "xxxx37094862xxxxxxxx";

BLYNK_WRITE(V1)
{
  int pinValue = param.asInt();         // assigning incoming value from pin V1 to a variable
  if (pinValue == 1) {                        // If value is 1 run this command
    digitalWrite(D4, HIGH);              //D4 output from Wemos D1 mini
  }
  else {                                           // If value is 0 run this command
    digitalWrite(D4, LOW);
  }
  Serial.print("V1 Button value is: ");
  Serial.println(pinValue);
}

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(D4, OUTPUT);
}

void loop()
{
  Blynk.run();
}

@Hannes.P Please remember to format any code you paste here… I fixed your last post, so you can look back at how it is done.

Blynk - FTFC

Hi guys I would need again help from you :hugs:
Also now I wrote a lot of codes, as much that I can no longer lost my view :joy:
Joke not really, but I had a question to a simple sequence. To understand better I copy below an extract from my sketch. Also I would realize a central function which means in my case:
Only if button V3 is pressed, the action from slider V4 can start, which means only when button V3 is pressed, I am able to dim an led which is conected on D3. Only dimming a led without any condition (in my case if pinValue == 1 in row 28) works but I would like to add it in my sketch :blush:
Thanks in the meantime :wink:

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

char auth[] = "b5a2426a237549448f9dff83a354xxxx";
char ssid[] = "Fritzboxxxxx";
char pass[] = "67033709486218110xxxx";

int pinValue = 0;                       //status from Button V1
int brightness = 0;                     //value from Slider V3

BLYNK_WRITE(V1)
{
  int pinValue = param.asInt();         // assigning incoming value from pin V1 to a variable (Button)
  if (pinValue == 1) {                  // If value is 1 run this command
    digitalWrite(D4, HIGH);             // D1 output from Wemos D1 mini
  }
  else {                                // If value is 0 run this command
    digitalWrite(D4, LOW);              // D1 output from Wemos D1 mini
  }
  Serial.print("V1 Button value is: "); // Output the value "pinValue" in Serial Monitor
  Serial.println(pinValue);
}

BLYNK_WRITE(V3)
{
  int brightness = param.asInt();       // assigning incoming value from pin V3 to a variable
  if (pinValue == 1){
  analogWrite (D3, brightness);         // D3 output from Wemos D1 mini
  }
  Serial.print("V1 Slider value is: "); // Output the value "brightness" in Serial Monitor
  Serial.println(brightness);
}

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);
  pinMode(D4, OUTPUT);                  // D4 is an output (digital)
  pinMode(D3, OUTPUT);                  // D3 is an output (analog)
}

void loop()
{
  Blynk.run();
}

Basically same general issue, so I merged your last post back into original topic.

Sorry I can not follow you…
I missing the forest through the trees :joy:

You 2nd to last post (above) was basically about same general issue as this whole topic… but posted in a new topic. But having multiple topics on same issue is not really allowed, so I merged your last post back into this original topic… hope this clears that up :stuck_out_tongue_winking_eye: