BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Help me to rotating this fan


#1

@Gunner Hi gunner. can you help me to rotating this fan ?
1 2

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);
  }
}

Image Gallery
#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 :stuck_out_tongue_winking_eye: ) appearance, then you would need short timers alternating back and forth… much like my LED example…


#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


#4

@Gunner gunner thanks. I’m change the time to 2000L its working.


#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 @Alexis_Cabrera is an expert at it :smiley:


#6

ah ah.
you are my teacher @Gunner.
don’t forget that.
:blush:


#7

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%

#8

@ErfanDL @Gunner :rofl::rofl::rofl:

Video_00401


#9

Any chance you could share the code?


#10

@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

#11

Video_00402


#12

Fantastic job @Alexis_Cabrera :smiley:


#14

i know it isn’t perfect, I realized it in 5 mn.
mine has a variable speed, not yours.
:joy::joy::joy::joy:


#15

thank you @Gunner
this can be improved, but it depends on the speed of rotation and the gif image used.
@kotelmach has the solution:
do not use variable speed, it’s better.
what a pity !
:joy::joy::joy::joy:


#16

@Alexis_Cabrera 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 :stuck_out_tongue:


#17

How to set image name ? in this code the R is your image name ?
thanks


#18

no, R is the rotation degrees


#19

but where is image name ?


#20

the name is not necessary

just virtual PIN is needed


#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 ?