M
M
Maxim Barulin2022-02-15 14:37:32
Arduino
Maxim Barulin, 2022-02-15 14:37:32

How to rotate a servo by a given degree without Servo.h?

Hello!
There is a sketch https://github.com/Slavenin/flutter_wifi_car/blob/... Pins
8-11 are used to control the wheels. When Servo.h is connected, the wheels fall off as it reserves pins 9 and 10 for its needs.
It is not possible to connect the wheels to other pins, since there is an expander board from the set on top and there are only inputs for the wheels on these pins.
I tried to google the function of controlling servos without Servo.h on the Internet, I googled several options but did not fully understand how to turn the motor to a given degree.
In the current implementation, the motors work, but at some point the board reboots or something like that, since the signal from the wifi module disappears and you have to reconnect.
Help, please, with the implementation of the function of rotation by a given degree.
PS: 2 motors, one turns the camera left and right, the other up and down.
PPS: arduino uno board

Answer the question

In order to leave comments, you need to log in

4 answer(s)
K
kalapanga, 2022-02-15
@kalapanga

So right in the sketch, the link to which you provided, there is already control of servos without Servo.h ! I don't understand what else you are looking for. This UNO, judging by the sketch, only accepts uart commands and turns the motors on these commands.
wi-fi, as I understand it, works on a completely different, separate device. That's where you need to look for what and why disappears there.

V
Vladimir Korotenko, 2022-02-15
@firedragon

well, take this servo.h and register free pins.
What is the problem?

A
Anton Shamanov, 2022-02-15
@SilenceOfWinter

do you have 4 wheels? then you need 4 pins for control, it falls off most likely due to a lack of power, try connecting only 2 motors / wheels - if the problem does not recur, then 100% power.

M
Maxim Barulin, 2022-02-15
@Slavenin999

The problem was solved by changing pin 2 to 7. I don’t know what’s wrong with 2, but after switching to 7 - everything works like clockwork!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question