Will this button circuit design work?

In this example if I want the default state of PIN 7 to be HIGH and have it become LOW when the button is pressed, is this design acceptable?

Not to get into unnecessary detail but the application is to control a set of pop bumpers and slingshots in a toy-grade pinball machine. The ball comes into contact with a metal spring which represents the trigger/switch, while at the same time it tolls over an area of the playfield where the underlying plate of metal the entire playfield is constructed from is exposed. This plate is covered in most areas by insulation so the ball is not making contact except in areas where it needs to short the metal (ground) plate to the switch activating spring via the ball.

In previous designs I put the switch on the 5V line, as I did for the player buttons that trigger the flippers. This works fine since the switches are not connected to the grounding plate in this situation, but will not work in the situation where the ball activates the switch by shorting it to the grounding plate.
See attached photo.

buton.jpg

nope - as far as I can see, pin 7 is always connected to 5V !
But why do you make things so complicated ? You could just get rid of the 5V part and the resistor, connect the button between 7 and GND , and use the internal pull-up resistor for pin 7 , configuring it as INPUT_PULLUP in your sketch

moses1592:
In this example if I want the default state of PIN 7 to be HIGH and have it become LOW when the button is pressed, is this design acceptable?

Yes, even better, that is THE most common way to do it :wink: And indeed, most just use the internal pull up resistors with pinMode(pin, INPUT_PULLUP)

septillion:
Yes, even better, that is THE most common way to do it :wink: And indeed, most just use the internal pull up resistors with pinMode(pin, INPUT_PULLUP)

??
on OP's picture, pin 7 is connected to 5V via the yellow and the brown wires - It won't be LOW when button is pressed .
If the yellow and brown wires are not connected together, than pin 7 is never HIGH, it is LOW if button is pressed, and floating if not pressed.
It would work if the resistor were between brown and yellow wires, and pin 7-->button->GND
but it won't work as it is on the picture :wink:

I wasn't talking about his implementation, I was just talking about the way of switching he states in that sentence. So default pulled high and switched to ground.

That idea is perfectly fine and is the most common way of switching in micro electronics. But you already pointed out, his implementation is wrong :slight_smile:

OK :slight_smile:

Read all about it here Inputs

Thank you guys for the info. I was unaware of the internal pull up. This would have made previous project designs so much easier. I modified my code by two lines and made some small changes to the circuit and it works perfectly. Now those two pins are normally HIGH and when the 'button' is pressed they go LOW.

For any newbie interested for future reference, here is the new circuit design. It is the diagram for the INTERNAL pull up on the right side.

Thank you again for the info. it is appreciated.

pullup.jpg