Hİ everyone. Im trying to control a stepper motor using arduino nano. I have two buttons to control the motor. While one is pressed down the motor will rotate clockwise and the other button will rotate the motor counter clockwise. But i can not get the system to work. Any help would be appreciated.
First thing to ask when there are buttons and the pinMode() isn't INPUT_PULLUP is to ask how you wired them. Specifically do you have either pull-up or pull-down resistors to steer the input when the button's not active?
ok that's one side of each pin, where does the other side go.
If you wire the i/o pin to 5v through the switch, the pin needs a resistor to ground as well. When the switch is open, the pin is pulled to ground to read low; without the resistor, it could float at any old voltage. When the switch is closed, it reads high.
Alternatively and more common, is to wire the pin to ground with the switch, and have the resistor pull the pin up to 5V. When the switch is open, the pin is high. when closed, it's low. And the Arduino has built in resistors to do the pull up, invoked in pinMode.