Slider, I need help with using slider widget in blynk app

I am using nodemcu esp8266
And blynk app
Yesterday I tried to connect blynk and blub using nodemcu…
It’s worked
today I am trying to use slider.
But I’m not getting how write the code. I am a complete begginer.
I searched a lot… But still have lots of confusion Can please help me.

To do what?

The slider can directly adjust the PWM value of a GPIO. Say you have a LED on GPIO 14 and GND (or D5 as silkscreened on the NodeMCU - best to always use the GPIO number)

You set the Slider like this and then it will dim or brighten the LED as you move the slider.

Or, using Virtual Pins, lets use V4, it can send a range value to the device using the BLYNK_WRITE() Function.

For example to control that same LED on GPIO14 set your widget like this…

And add this to your basic Blynk Blink sketch…

In void setup()

pinMode(14, OUTPUT);

And then add this Blynk function to your sketch. Anywhere before or after your void loop()

BLYNK_WRITE(V4){  // This function gets called each time something changes on the widget
  int value = param.asInt();  // This gets the 'value' of the Widget as an integer
  analogWrite(14, value);  // this send a PWM signal based on 'value' to the GPIO pin
}

That’s basically it.

Lots of examples and more documentation in the links at the top of this page…scroll up to see them.

Thanks a lot.

I am trying to use slider to dim the blub .

I will try this code and let u know.
Thanks a lot :blush:

Can I use this code to control The fan speed?

1550468165712-1003644373
I will connect nodemcu( pin d5 )to relay and than The fan?
Will it work?
I am a beginner… I just need help.
Thanks in advance.

Analogwrite does not work with digital pin you have to use digitalwrite

Try tip testing with your board und relays

in the community there is a lot to do with fan switch relays and so on

When I use analog write…
ND connect to Bulit In led it works. …but when I use digitalwrite it’s not

@SANJANA, It’s much better if you copy and past your code (using backticks so that it displays properly) rather than posting photos of your computer monitor.

It’s also much better if you explain in words, diagrams, pictures etc what it is that you’re trying to achieve with your project. Your other thread (which @Gunner has now merged for you) asks about dimming an LED, and here you’re trying to control some sort of fan via a relay using an unknown type of widget in your app. Reading between the lines I’m guessing that the widget is a slider ad that you’re hoping top control the fan speed with the app. This clearly wont work if it’s a mains voltage fan and you’re controlling it with a relay, as the relay is a simple on/off device.

The point is that if you ask one line questions and give vague one line answers when others provide suggestions then you wont get the right information from people and they’ll very soon tire of trying to help you.

@markop, it is possible to use analogueWrite to a digital pin, it’s a technique I use all the time when dimming my LEDs. On the NodeMCU, all the digital pins can be used in PWM mode using analogueWrite. The NodeMCU uses PWM values of 0-1023 and if this is used to drive a single LED directly, or a strip of LEDs via a MOSFET then the LEDs can be dimmed from zero to maximum brightness.

Pete

@SANJANA @manju1 Please don’t create new user accounts for the forum to discuss the same issue. I’ve suspended your @manju1 account on the forum (note that this is not connected in any way to the accounts you’ve created in the Blynk app, they are totally independent). I’ve merged your new post back in to this thread.

I’ve also edited your post to put backticks at the top and bottom of your code so that it displays correctly. In future please do this your self, like this:

Blynk%20-%20FTFC

As I said earlier, a comprehensive description of what it is you are trying to achieve is the best place to start.

Pete.

1 Like

it depends on the fan you use: voltage, intensity.

1 Like

better use Mosfet driver

iam using nodemcu and arduino ide
its a project given to us.
please do help !

its not the SAME persons account @PeteKnight .
we r working in group as this group project .
one of my friend post all the code in detail
im new to the blynk community,iam sure how to use it.
can please help with the code…

Then please work with one account.

ok , can u help with the code and connections ? plz

We help you learn about Blynk… how to find the Documentation, learn about the commands, assist with some tidbits and advice, as we have already tried to do.

But we are NOT here to teach you programming or how to do your projects.

1 Like

ok thanks @Gunner

@SANJANA can i have yr email?