LILYGO SIM7000G - Issue using PWM controlling a DC motor and a servo at the same time
Hi there..
I have had some code working for a long time where I used a LILYGO SIM7000G unit connected to a DRV8871 motor driver through pins 32 and 33, and a servo connected to PIN 12. But suddenly/lately it has started to fail and the servo is pushed all the to one end as soon as I do a analogWrite to PIN 32 or 33. I have not done any changes that should have affected this. I also was able to reproduce the problem with a small test program.
#include <ESP32Servo.h> Servo myservo;
#define SerialAT Serial1
void setup() { // put your setup code here, to run once: Serial.begin(115200); myservo.attach(12, 1000, 2000); pinMode(32, OUTPUT); }
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Loop...");
myservo.write(0);
delay(2000);
myservo.write(180);
delay(2000);
//If I comment out the line below, the servo works fine "every loop", //but the servo only works the first round when this line is active. analogWrite(32, 50); //This starts the dc motor but also pushes the servo to the end and it stops working. delay(2000); }
Any ideas folks? :)
Source: rwaldron/johnny-five