i have a custom atmega328p board which have connected to pin 9 the gate of a MOSFET. If i run a simple sketch like:
void setup() {
}
void loop() {
analogWrite(9,70);
}
The motor connected to the mosfet works just fine, from 70pwm to 255pwm.
On the other sketch i'm receiving serial data from an android app via bluetooth. Ive 2 Servo motors and a DC motor connected to the mosfet. The 2 servos works like expected, the DC motor doesn't spin unless i use a 255pwm.
void loop() {
if(Serial.available() > 0){
state = Serial.read();
}
if (state == 'S') {
servoONE.write(90);
servoTWO.write(90);
analogWrite(MOSFET,MOSFET_LOW);
}
else if (state == 'F') {
analogWrite(9,70);
servoONE.write(90);
servoTWO.write(90);
}
else if (state == 'L') {
servoONE.write(MAX_SERVO);
servoTWO.write(MIN_SERVO);
}
else if (state == 'R') {
servoONE.write(MIN_SERVO);
servoTWO.write(MAX_SERVO);
}
else if (state == 'Q') {
analogWrite(MOSFET,MOSFET_HIGH);
servoONE.write(MAX_SERVO);
servoTWO.write(MIN_SERVO);
}
else if (state == 'E') {
analogWrite(MOSFET,MOSFET_HIGH);
servoONE.write(MIN_SERVO);
servoTWO.write(MAX_SERVO);
}
}
Do you know why the same motor works on the first sketch with any pwm above 70 and on the second sketch it only works at 255?