Pages: [1]   Go Down
Author Topic: Pinball "Shoot This" light + hit sensor on one pin?  (Read 881 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What up Arduino community! Getting started on a big project; building a half-scale pinball machine driven by an Arduino Mega.

(Also sorry if this is in the wrong place... couldn't really determine which forum to put this question in.)

The Mega has a lot of pins, but my board has even more components. My first instinct was to cut down on the number of components, but then my inner engineer kicked in and is wondering if there is another way to conserve pins.

A lot of the targets on the playfield consist of just a small momentary button paired with a "shoot this" indicator that lights up or flashes when the target gives a high number of points.

I'm wondering if I can put the LED and a normally-closed momentary button together on one pin. I'm fairly new to Arduino so I'm not certain as to the best way to do this. Would I set a pin to 'digital input', then run power from the 5v pin through an LED and the momentary button into the input pin?

Also, would there be a way to have the momentary button detection still work without lighting the LED? Possibly by allowing only a small amount of current through it, so it only glows very dimly, but with enough current for the Arduino to detect the button being opened?

Here's the target I'm trying to build...



And here's the reason I'm using a Mega and trying to conserve pins...




Any help appreciated! Thanks!

Wes
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 652
Posts: 50852
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I'm wondering if I can put the LED and a normally-closed momentary button together on one pin. I'm fairly new to Arduino so I'm not certain as to the best way to do this. Would I set a pin to 'digital input', then run power from the 5v pin through an LED and the momentary button into the input pin?
If you set the pin as an input, and wire it the way you indicate, the LED will only come on when the switch is pressed. In which case the Arduino won't even know anything about the LED.

You can't simultaneously use a pin as input and output. One at a time, and the mode can be changed at any time. Just be careful how you wire things.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you set the pin as an input, and wire it the way you indicate, the LED will only come on when the switch is pressed. In which case the Arduino won't even know anything about the LED.

You can't simultaneously use a pin as input and output. One at a time, and the mode can be changed at any time. Just be careful how you wire things.
I said a 'normally closed' momentary button; the LED would be lit when the button is NOT pressed, then turn off when the button IS pressed (then come back on when the button is released, unless the Arduino could in fact tell that the button was hit and then turn off the LED somehow. I'm thinking it could turn the pin to output/HIGH, so there would be 0v between the digital pin and the 5v pin on the other side of the LED?)
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5281
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's easier to use GPIO extensions over I2C (p.e. MCP23008). Some of them even have interrupt logic so you can build almost anything you'd do with the internal pins (OK, not truly as fast, but for a pinball more than fast enough).
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It's easier to use GPIO extensions over I2C (p.e. MCP23008). Some of them even have interrupt logic so you can build almost anything you'd do with the internal pins (OK, not truly as fast, but for a pinball more than fast enough).
Can you point me in the right direction to employ... whatever that is? I'm fairly new to the nitty-gritty Arduino stuff. Thanks!
Logged

Switzerland
Offline Offline
Faraday Member
**
Karma: 112
Posts: 5281
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some points (better links) to start with:

http://www.adafruit.com/blog/2010/09/02/everything-you-need-to-enjoy-a-brand-new-mcp23008-mcp23008-library/

http://code.rancidbacon.com/LearningAboutArduinoMCP23S08

Each chip gives you another 8 IO pins and you can add up to 8 chips to one Arduino (makes 64 additional IO pins).
Logged

Pages: [1]   Go Up
Jump to: