I have a pinball machine thats an old electro mechanical type. I want to add LED's and do some fancy programming on an Arduino to animate the lights according to the score value of whatever target you hit playing the game. I have the programming- the LED, and the PWM dimming circuity and control down. I have never worked with input signals to Arduino or much circuit design at all.

The pinball machine has a relay that opens when it needs to move a score reel, e.g. the reel holding the "tens" position will accuate 5 times if you score 50... so that relay will pulse 5 times and open and close a circuit. The circuit runs on 26 V AC.

Whats the dirt simple stupid way to simply track this as a state change (or edge detection). I could not care less about the actual voltage, in fact if I could simply measure conductivity without worrying about input voltage etc I would. I cannot modify the game but for adding a wire to each pole of that switch. I cannot FRY the Arduino by putting 26 V AC (or for that matter DC) into it (grin).

Considering half waver smoothed rectifier but unsure about how to calculate reisitor and capacitor needed then unsure about voltage scaling, do it before or after rectifier?/?

Or... is there is truly simple method I don't know about (which would cover a very large area or knowledge).

If you can help me with suggestions and resources to help me figure out HOW to build a functional circuit that would be great.

Remember all I care about is state change, so if it ends up being an input voltage detection I could care less if it goes from 0 -> 5 V or 0 -> 2 V just so long as i can detect the switch above noise.

THANK you so much for your advice.


You could power a small 24V relay via a bridge rectifier and small smoothing capacitor. Use the relay contact outputs to feed the appropriate dc voltage to the arduino. Here: -

enter image description here

The 26V ac when present will activate the relay via the bridge and the small capacitor (10uF) should keep the rectified peaks from chattering the relay at AC (x 2) frequencies.

It's "x 2" because (say) 50Hz AC adopts a 100Hz profile when bridge rectified.

You could also use an opto-isolator fed from a bridge circuit too. This would need a smaller capacitor and a series resistor with the diode of the opto. The transistor part of the opto could switch 5V (or 3V3 or whatever DC you are using) to the arduino.

  • \$\begingroup\$ Great idea... this simplifies things greatly because I can worry less about arduino input voltage frying etc etc. So Basically I just run a wire from the positive pole of the switch through a little capacitor then to the relay which also goes to ground. Then get a nice little 5 V DC wall wart and run it to the other side of the relay into the Arduino. Simple, and easy! Let me know if I FUBAR'd anything in your idea here. And I looked, your exactly right... 24V relays are available and cheap! awesome. +1 for being very helpful \$\endgroup\$ – rufessor Apr 16 '13 at 19:25
  • \$\begingroup\$ Sorry- Do I need a diode in there or will the capacitor alone serve to dampen out the relay with AC coming into it? Seem like I want a Diode- which also will pull about 0.7V out of the input signal bringing it almost exactly to 24V! \$\endgroup\$ – rufessor Apr 16 '13 at 19:33
  • \$\begingroup\$ Answering my own question- I think** You said a bridge rectifier so that means a diode at its simplest. Thanks \$\endgroup\$ – rufessor Apr 16 '13 at 19:33
  • \$\begingroup\$ @rufessor - I've added a small circuit - let me know if you don't understand it please. \$\endgroup\$ – Andy aka Apr 16 '13 at 19:44
  • \$\begingroup\$ Got it- I think I understand this- its a full wave smoothed rectifier- I was thinking half wave... but this is just about as easy to build. All ready called my local electronics shop and they have everything I need in stock. Should be fun! THANKS AGAIN. \$\endgroup\$ – rufessor Apr 16 '13 at 19:59

@AndyAka's answer excellently describes a possible approach to addressing the requirement.

This answer does not preclude the other one, but points to a single-IC pure solid-state implementation of the same approach.

Use an AC-DC optocoupler with a logic level output, such as the Fairchild HCPL3700 or similar. I have selected the cheapest (for single units) such part from the Digikey database; just search for AC-DC optocouplers with logic level output, for alternatives:


The implementation for the specified requirement is provided in the datasheet:

Opto implementation

The advantages of this solution are:

  • No discrete bridge rectifier or diodes required, rectification is internal
  • No mechanical relay, so less likelihood of device failure
  • Inexpensive: Entire solution including resistors and capacitors for under $4.50
  • Damping can be set up easily (see datasheet) to eliminate signal chattering
  • Output is designed specifically for TTL logic level
  • Less parts involved, less points of failure.
  • Available in SMD or through-hole DIP, choose whichever is preferable

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.