[SOLVED]Issues Controlling Servo on Intel Edison with Blynk Virtual Button (for Capstone project)

Hello guys

Im trying to connect servo motor to intel edison board. As a controller i use blynk. Servo has connected to pin8 on the board for data. The code which is below, doesnt work. It should run when i press V0 button on blynk app. Please help me!

Thank you

#define BLYNK_PRINT Serial    
#include WiFi.h
#include BlynkSimpleIntelEdisonWiFi.h
#include Servo.h

const int servoPin = 8;

int buttonState = 0;
int directionState = 0;
Servo myservo;
int pos=0;
char auth[] = "8b92e4ea7fe549ca96abb0c46294b869";

char ssid[] = "HTC";
char pass[] = "31414900";

void setup()
  Blynk.begin(auth, ssid, pass);
  if (directionState == 0 ){
    if(buttonState == 1){
      directionState =1;

      for (pos = 0;pos<90;pos=pos+1){
   else if (directionState ==1){
      if(buttonState == 0){
        for (pos =90;pos>=1;pos=pos-1){

void loop()

Just curious, Android or iOS?

Please start of with properly formatting your code.

code here

gives you formatted code like this

int i = 5;
void func()
   int x = 10;

Alot easier for us to read.


Try switching the pin assignment on the Button widget to the physical pin, 8. Then start your Blynk app again and push the button widget. See if your servo works now? If it does, then you can re-assign the button back to V0 and it should work again until the next time you reset the board. Then you will have to do these steps over again.

I have had this issue while using iOS. Let me know your results.



I have tried what you said. I can tell that it is close to run when i assign the button to physical pin 8. But this time servo doesnt work properly as i wish. when i press the button one time as i written in code it should open-close 90 degrees.But it doesnt. When i repeatedly push the button in push mode, the servo opens a little and close a little but does it randomly and not 90 degrees at all.

When i re-assign that V0, it doesnt work.

Should i change the code to run this?


@heisst It is not clear what you are trying to accomplish with the for loop… as you only have one button assigned, I am guessing that the servo rotates one way when the button is pressed and the other way when button released.

If so, it is much easier to just assign start and stop positions like this

  buttonState = param.asInt();  // Get button state (ON or OFF)
   if (buttonState == 0) {
    myservo.write(0);  // Move servo to 0 position
  }  // end if
  else if (buttonState == 1) {
   myservo.write(90);  // Move servo to 90 position
  }  // end else
}  // end Blynk Function

If you want granular control, best to use a step or slider widget instead.

  pos = param.asInt();  // Get widget position - set widget scale from 0 - 170 for a typical servo
    myservo.write(pos);  // Move servo to pos position
  }  // end Blynk Function

You might just have to wait until the iOS stuff is all ironed out. I am not really sure as I have had the same issue and have at first attributed it to iOS. But I have no way to verify 100% since I am still waiting for my Android device.

As is the usual suggestion, try to get your code to work without Blynk and then add it back in. I would also start by eliminating anything to do with virtual pins and see where that gets you.

Keep me posted

Thank you! I have used your code to control it via slider and it works now

1 Like