Read the title. What is the code?
No code needed Reduce the voltage or PWM it with e.g. a NE555.
With code, use PWM (analogWrite).
Hi, @techloser
Is this associated with this?
https://forum.arduino.cc/t/creating-a-controlled-spinner/994092
If you want someone to write the code for you, then there is a payed code section of this forum.
Otherwise;
Can you please tell us your electronics, programming, arduino, hardware experience?
To add code please click this link;
Thanks.. Tom...
So I'm trying to make a machine that will spin to a certain degree depending on what button is pressed. The way I was thinking was by using resistors to control the amount of voltage received, and have different resistors for different buttons. Is this machine possible to make using this method or another?
Sure, but why? Why not use regular digital pins and internal pull-up resistors for the switches?
I suggest to use a motor of some sort. After deciding on a motor, then choose an appropriate method to control it.
I should look up how to drive motors. Just using a resistor to limit the amount of current flowing through it will affect only the speed and torque of the motor and you don't get very much control using that. Especially if you want the motor to stop at a "certain degree", I am assuming you mean position here.
Note that a series resistor does not limit the amount of voltage going to a motor, but limits the current.
The two types of motor that allow positioning are a servo motor system, or a stepping motor. A servo will only have a limited amount of movement say 100 to 170 degrees depending on the type.
A stepping motor can turn any number of rotations and stop at a specific point. However it requires to be calibrated every time it is switched on, normally done by driving it until it breaks some limit switch.
I want to make the DC motor pinwheel stop every 4 seconds when the circuit is closed. Also have it continue spinning shortly after it stops.
Can I program....
Short answer is yes, it can be done. But you should post the code you did so far and which might not be working to your satisfaction, and explain what it does wrong.
Have a look at the IDE examples "blink" and "blinkwithoutdelay" for some ideas.
But whatever you do, don't attach the motor direct to an i/o pin with no electronics in between: as a minimum a transistor, and if you want direction control you'll need an h-bridge of some type,
How could I make a machine that starts spinning a DC motor when a button is pressed, and stops when not pressed?
Get a power supply and connect it to a DC motor, add a push button in the power line. No Arduino board is needed.
If you want to try something with an Arduino board, then it can be simulated in Wokwi. For example with an Arduino Uno and a button as input and a led as output.
Don't really need an Arduino for that. Wire the button switch in series with the motor and power supply. Close the switch to run the motor. The button switch and power supply must be rated to handle the motor stall current.
@techloser, stop cross-posting. This is your only warning.
A whole lot of mess merged together.
Good luck. Y'all are going to need it.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.