just started to attempt to code and such for a motor involving a school project of mine, I'm having trouble finding a way to have the button pressed against making the motor go clockwise and then once the pressure is gone and the button is no longer pressed making the motor rotates the other way.
Hello
Welcome to the worldbest Arduino forum ever.
It seems to be a school assigment, isn´t it?
We need some additional information.
Post your current sketch, well formated, with well-tempered comments and in so called
code tags "< code >" and a detailed circuit diagram to see how we can help.
Have a nice day and enjoy coding in C++.
You need one of the the following components and Arduino UNO:
1. L293D IC

2. L293D Based Motor Shield

3. L298 Based Motor Driver

With respect to @GolamMostafa the L29x are not very good drivers by todays standards. They use old technology and are very inefficient. They drop 2V to over 4V of the motor supply voltage and dissipate that power as heat.
I will admit that they are cheap and plentiful and will work fine with smaller motors.
They are OK for learning, but for a serious project or one that is battery powered, more modern drivers make more sense.
Let OP start with the L293D IC and a simple 0V-6V DC Motor. If he is interested, I can provide the connection diagram and coding hints/solution.
… and a beefy power supply.
Beefy powersupply means you can not power a motor from an IO-pin. You would overload and destoy the microcontroller. And the 5V pin of the microcontrollerboard can not supply the motor except for 5-8mm tiny motors. You will need an extra and beefy enough powersupply. Google for driving a dc motor with arduino
Are you sure that the motor shall run always ? Even with the button released?
OP can test with the following motor (Fig-1, say for 20 sec) and 5V supply of UNO. They rotates even at 1.2V terminal volt and draws tiny amount of current. These are usually used in a four wheel toy robot car. Anyway, L293D refuses to work below 4.5V. So, it is better to use a 9V battery at the Vcc2-pin of L293D IC. 5V of UNO can be used at the Vcc1-pin and other logic pins of L293D IC (Fig-2).

Figure-1:
Figure-2:
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
