I am new to arduino and working on a small project of my own. I tried making a button which can be pressed to use my step motor. Unfortunately, either the button does not seem to work or (and this is what I am thinking of) the resistor is preventing the button from ever reaching the motor (when pressed) through electricity.
Whenever I wire the white wire in another line, instead of the line where the resistor is set, it does what I expect it to do (but only non-stop). However, when I put the white cable in line with the resistor, it doesn't go off.
See the image below to get an idea of how I set it up:
It looks like you need to move the orange wire up one row.
The more accepted way to wire a switch is to wire one side to ground and the other side to an input with the pinMode set to INPUT_PULLUP. The switch will read HIGH when unpressed and LOW when pressed. See the state change for active low switches thread.
You might not end up with the number you expect due to floating point truncation. When I was in school, some people answered exam questions with answers like, "2.9999999" because the calculators the school lent out, didn't round numbers. All those people got half marks.
Also, 5 milliseconds is very near the borderline for some switch bounce, it's really too short for some.
You never need to check a value you've already checked. So this:
Everything is hard-coded. So whatever you see is whatever happens. There is nothing dynamic and therefore no possible pitfalls such as commas (or dots) in ints.
Hi,
Can I suggest a simple rule when it comes to these tactile buttons.
Make your two connections to the two diagonally opposite pins, this will ensure you are across the open contacts.
A DMM? I am not too familiar with these terms, but I honestly think I am doing something wrong with the bread bord. Let me show you the complete bread bord. Maybe that will clear things up as to how I have everything set up.
A Digital MultiMeter.
Try this code, it will read the button pin and make the on board LED turn ON when you press it.
Also if you open the IDE Monitor window and select 9600 baud it will tell you the button status.
Have you moved the orange lead as shown in my previous post?
Did you write this code all at once or in stages.
If in stages you should have a similar code to test your button, and other codes to test each of your hardware items, before combining them.
Tom...
PS, We need a circuit diagram, please draw one and post an image, include component names and pin labels.
Yes I did change the orange one. However the images are from before. I hadn't made any pictures after update. I'll do the rest of what you said. I'll update you soon. Pretty much 4 AM where I am right now so my brain is fried as well
Hey Tom, back after the test. Your code does work. Interesting part though: The button itself does @!*@ all. Apparently the button is for the show. As mentioned in my previous comments: When I unplug the white cable from the resistor it returns "button pressed". If I put it in front of the resistor again it says "button not pressed". I'll get busy with the diagram.
That's what it should return when I press the button, this isn't the case however. Regardless of what I press, the button doesn't return any responses based on me pressing it or not. It's the fact that I remove the white cable from the resistor that gives me the right responses.
Hi,
Okay remove the button from the circuit.
First connect orange to white, (the other ends, white should go to D7, Orange to 5V) and the 10k between gnd and the orange white connection.
See what is indicated.
Second remove just the orange wire from the connection, leaving the white connected to the 10K.
See what is indicated.
Those "tact" buttons often do not actually fit into a breadboard unless you use pliers to straighten out the leads. Even then they may not actually connect into the breadboard.