Servo motor with esp8266

I'm trying to control a servo motor with esp8266 but it doesn't respond. The same sketch works normally on Arduino. I know it takes 5V for the servo so I'm using the esp VIN pin and it plugged into a computer's USB port. I already measured the output of this pin and it has 5V. Any idea what it could be?

#include <Servo.h>

Servo meuservo; 

int pos = 0; 

void setup() {
  meuservo.attach(6);
}

void loop() {
  for (pos = 0; pos <= 180; pos += 1) {
    meuservo.write(pos);
    delay(35);
  }
  for (pos = 180; pos >= 0; pos -= 1) { 
    // descrescente
    meuservo.write(pos);
    delay(35);
  }
}

Are you sure that you have the servo plugged into pin 6 of the ESP8266. Should perhaps the pin be referred to as D6 in the attach() function ?

I've already tried 6, D6.. I've already connected all the other pins to see if the sketch was referring to D6 or PIN6 and nothing and I've already tried other pins like D4 for example.

Simplify your tests by using the Blink sketch with different pin assignments and use an LED or multi meter to confirm which pin is being accessed

does the servo make a humming noise of sorts , it could be with not having enough power

Doesn't make any noise

Use differnt pin GPIO.
GPIO6 is used for flash comms.
Pick one on the other side of the board & all should work :slight_smile:

Really!! I even used a logical level converter but it didn't work.

I'm going to try!! Thanks!!

It worked with D1!!! Thanks a lot!!!