I tried l298n before but its output voltage wasn't high
so I use relay shield but it seems that the car can only go forward or stop
Can I control the speed and direction of dc motors?
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up.Sign up to join this community
Using a mechanical relay to control the speed is not a good idea. But you can control the directions.
I prefer you to use Solid state relays (SSR) to do this. Arrange 4 SSR as Hbridge and Use PWM to control the speed.
or you can use the devices like this which has direction control as well.
Yes you can, but the easiest way is by using a "motor shield". There are more options than just L298N.
Are you sure it was the voltage that wasn't high enough, its normally the current (Amps)?
To do it with a relay you need to change the polarity of the feeds to the motor. You could do this with 2 relays both connected all the time, but if you close the wrong one, you will short everything. It would be better using a motor controller.
Most refer to relays when talking about mechanical devices which are either closed or open. If you arrange several in an H-bridge configuration, you can make you car go forward, stop and reverse. But controlling speed is not possible.