ErfanDL
December 6, 2018, 10:18am
1
@Gunner Hi gunner. can you help me to rotating this fan ?
I’m trying this cod but only showing one image. the V3 is image widget
BLYNK_WRITE(V9)
{
int pinValue = param.asInt();
if (pinValue == 1)
{
digitalWrite(Relay_9, LOW);
Blynk.virtualWrite(V3,1);
Blynk.virtualWrite(V3,2);
}
else if (pinValue == 0)
{
digitalWrite(Relay_9, HIGH);
Blynk.virtualWrite(V3,3);
}
}
Gunner
December 6, 2018, 10:38am
2
I moved your issue into your own topic.
I only see two distinct images… and as far as the “ON” side, those two virtual prints would happen so fast that you would only see the image #2 anyhow.
If you want to have the “.gif” (pronounced giraffe ) appearance, then you would need short timers alternating back and forth… much like my LED example…
#25 - Das Timed Blinkin’ LED… Without any delay() - AKA Timerception
This is simply just two nested Lambda functions using BlynkTimer and two different timer types to flash a Virtual LED ON for 1 second and Off for 1 second… If this is placed in the void setup() it just repeats in the background… marquee style.
Here it is integrated into a bare bones Blynk Blink Sketch… There should be enough commenting to figure it out from here. LED Widget set to V0
#include <ESP82…
2 Likes
ErfanDL
December 6, 2018, 11:04am
3
thanks gunner. I tried your code. but it’s very fast flashing the fans and not rotating. I’m set the timer to 1000L
ErfanDL
December 6, 2018, 11:11am
4
@Gunner gunner thanks. I’m change the time to 2000L its working.
1 Like
Gunner
December 6, 2018, 11:12am
5
You need to adjust both timers to your own needs… but they also need to be in sequence with each other typically 2nd is 50% of 1st
FYI, I have not actually tried rapidly changing any images yet… but @Blynk_Coeur is an expert at it
2 Likes
ah ah.
you are my teacher @Gunner .
don’t forget that.
1 Like
why not use the property “rotation” ? with only one image and one timer?
//Rotation property
Blynk.setProperty(V3, "rotation", 90); //0-360 degrees
//Scale property
Blynk.setProperty(V0, "scale", 30); //0-100%
//Opacity property
Blynk.setProperty(V0, "opacity", 50); //0-100%
4 Likes
Any chance you could share the code?
2 Likes
@Toro_Blanco
int Speed, R;
void setup()
{
timer.setInterval(100, Fan);
....
}
BLYNK_WRITE(V27) {//slider 0 to 4
Speed = param.asInt();
}
void Fan() {
R = R + (10*Speed);
if (R >= 360) {
R = 1;
}
Blynk.setProperty(V0, "rotation", R); //0-360 degrees
5 Likes
Gunner
December 7, 2018, 12:24am
12
Fan tastic job @Blynk_Coeur
1 Like
Gunner
December 7, 2018, 9:01am
16
@Blynk_Coeur I really like your use of the rotation properties command… looks more than smooth enough , considering you have then converted it to a gif for forum presentation. I didn’t even think of those set property features… I would have been rapidly changing 2-3 images back and forth
1 Like
ErfanDL
December 7, 2018, 9:15am
17
How to set image name ? in this code the R is your image name ?
thanks
1 Like
no, R is the rotation degrees
1 Like
ErfanDL
December 7, 2018, 9:21am
19
but where is image name ?
the name is not necessary
just virtual PIN is needed
ErfanDL
December 7, 2018, 9:24am
21
Ahaa. OK but I want when the fan turning off the fan color changed to red color. is that possible with one image widget ?