I'm using STM32 F401RE
board and i'm trying to do a very simple thing. I want to control a servo (0-180). The problem is that it looks like it doesn't respound to my commands.
#include "mbed.h"
PwmOut myServo(D9);
int main() {
myServo.period_ms(20);
while(1)
{
myServo.pulsewidth_ms(1);
}
}
The Servo Motor i'm using. At the beginning i though something is wrong with my board pinout or pinout meaning , but it seems like D9
is the same with PC_7
. My servo is properly installed and is supplyed by 5V source. I tried many tutorials i've found online but no one worked. This is the class with all methods.
If i generate the same PWM with an oscilloscope it does work.
I figured out what the problem was. I didn't had all grounds connected together because i was powering the STM32
via USB. When i was testing, the STM was connected to PC so the ground of the servo was different from the ground of the STM32.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.