Hi everyone, I'm not really sure where to post my problem, this is my very first post here, sorry if this isn't the best place.
I'm making a system with an Arduino UNO, an A4988 driver and a stepper motor, i've been doing tests and everything seems to work fine, I added a potentiometer to control the speed and it also works fine.
But when i'm adding 3 pushbuttons: one to make the motor run left, another one to make it run right and the last one to make it stop, somethings not working now.
When I'm pressing the button to run right and to stop works fine, but the other one doesn't work at all.
The code seems to be fine, and I added some lines to check what was going on, and watching at the serial monitor, the digitalRead of the left button doesn't change. I've tried different switches, different cables and nothing, I got a LED attach to the output of the switch and it shines when I press the button, but the pin doesn't get that change.
This is how I got it connected (sorry for the crappy drawning):
Here it goes. All three buttons are conected to power (5V) at one side, and a 10k ohm resistor (which goes to ground) and an input pin of the arduino. But only two of them seems to work.
Hi, the connections in the switches are correct i think
PIN 1 = 5V
PIN 2 = nothing
PIN 3 = 10k ohm resistor + wire to an input in the Arduino
PIN 4 = LED
All the three switches are connected the same, and two of them works. In the other one I get the LED lighning when I push the button, but no signal gets to the Arduino (it's supposed to change from 0 to 1 when I pushed it).
I've just tried it and nothing. I've tried with other resistors and removing all the LEDs. Still nothing. What I don't understand is that one of the buttons, the one to run the motor in one direction works perfectly, but the other one, with the same code, the same connections, doesn't work and I don't get any signal in the PIN where is connected I've tried other PINs and it doesn't matter, so I don't know what else can I try.
Are you sure that the switch actually works and shorts the connections that you expect when you press it ? If you move all 3 buttons to different places in the circuit does the problem follow the button or stay with the pin ?
Yes, I've tried moving the button in different places of the breadboard and still the same issue. I've added the LEDs to check out that the button actually did what they were supposed to, and when I pressed the buttons the LEDs light.
I've also tried, right now, changing the the pull down connections that I had into a pull up connections, but it doesnt solve the problem. When I pressed that button the input doesn't change
Ok, solved, I guess something must be wrong with the switch, even I've tried a couple of them, but using a cable directly instead of a switch works fine. Maybe the breadboard doesn't make good connection.