Hello there,
I wonder why I am not able to blink an LED connected to digital pin 9 by a virtual button (10)?
Code:
BLYNK_WRITE(10)
{
digitalWrite(9, HIGH);
}
I know I can do it directly by placing the button on digital pin 9 though I want to know why I can’t do it this way.
And please, how do I control a virtual LED by a virtual button? Can you provide me with the code?
Thank you
Have you specified pinMode for pin 9? In case you do direct mapping pin->widget it is done automatically, but in your case you need to that manually for pin 9.
@Dmitriy
Thank you it worked, but when I pressed the vitual button the physical LED turned on and kept on even after turning off the button :\ why is that?
On the Uno pin 9 can be both a pure digital input or output pin OR a PWM output pin. The function depends on how you set pinMode () and what function you use - digitalRead ()/Write () or analogWrite (). Since you want PWM output to control the brightness of your LED, analogWrite () is what you want to use.