Well, i got a Robot with a Hc-SR04 Ultra sonic sensor, a Servo, a DC Motor with L298n H bridge, and a Uno.
The goal is that the Servo turn as soon as there is a Threshold distance reached. If i only hook up the Servo and the Sensor, everything just workes fine. As soon as i get the Motor included, the servo just starts turning and tries to go far beyond 180 degrees. The Sensor works fine with just the motor running. As soon a the servo gets connected same weird behaviour.
So hopefully anybody out there u could help!!!
i tried what u said. Did work. I also used an external battery to power the servo. As i was messing around with it i bit more, i figured that the problem could be a software one. As soon as i write 'myservo.attach(servo_pin)' it doesn't work anymore. Even though i don't have the servo connected.
So i finally found out what is causing the trouble...
It's not a current problem, but a library one. When i drive the servo without the library everything works just fine. After some research i think at has something to do with the timer the library is using. Driving the servo oldschool, without the library isn't really perfect.
Any suggestions how to get it working with the servo.h library? I always thought the uno could at least do two simultaneous pwms. correct me if i'm wrong. (the second pwm i'm using is the one for the motor shield).