I'm trying to essentially build a Raspberry Pi powered pachinko machine, where I need to detect when a magnetic marble falls through a gate/opening/region. Are there any electrical components/breakout boards/ideas I could use to detect such an occurrence? I've been debating on using a Hall Effect Ratiometric sensor paired with an ADC converter and GPIO ports to detect magnetic fluctuation to detect when the marble passes, but I didn't know if there were any better ideas. Maybe some sort of gate that won't mess with the marble's trajectory? A light or motion sensor? Something that can quickly detect the marble's presence?

For reference, here are the magnetic marbles that I'm using. I'm using a Pi Zero too.

  • those magnetic marbles may be too brittle for your application .... also, what material are you planning to use for the pins?
    – jsotola
    Mar 26, 2018 at 4:29
  • Hmm do you think those marbles will shatter? I actually won't be using any pins :) I'm really building a sort of Rube Goldberg machine that students will assemble in order to guide a falling ball down through a series of gates/openings, where I need to detect when they're successful in making it through one of the gates.
    – Ampp3
    Mar 26, 2018 at 4:42
  • I'm wondering if the phototransistor setup here might work well for this... my only worry would be if the phototransistor would detect a ball moving very quickly. youtube.com/watch?v=5xQcbjkGq0A
    – Ampp3
    Mar 26, 2018 at 5:09
  • the marbles may shatter if dropped on the floor or if banged together
    – jsotola
    Mar 26, 2018 at 5:13
  • I've been trying to run a few experiments :) I just thought it wise to ask the hive mind if there were any simple ideas that I might not have thought of.
    – Ampp3
    Mar 26, 2018 at 5:14

2 Answers 2


A light sensor usually works pretty well when you can illuminate it with a LED and make sure that the passing marble will block that light.

enter image description here

You only need an ADC / comparator when you want to measure / detect a very specific illumination level. If you instead can make sure there's enough illumination difference to toggle between 0 and 1, you can connect it directly to a digital pin.

  • I like this idea, and I see a few other people who have used similar solutions. Thanks for the idea!
    – Ampp3
    Mar 29, 2018 at 2:39

You don't specify the size of the region through which the marbles pass.

If a Hall effect sensor can be positioned so that a marble always passes within a millimeter or so then it would seem a natural solution. No need for an ADC. The ones I have (OH3144E) default to Vcc and pull to ground when a magnet is close.

  • Sorry for the lack of details, I haven't nailed down the exact dimensions, though the gap is planned to be around 3 inches wide. Sounds like a Hall Effect sensor might not be my best bet then.
    – Ampp3
    Mar 29, 2018 at 2:39
  • I wouldn't have thought so, but I'm just a hobbyist with very limited experience using one type of Hall effect sensor.
    – joan
    Mar 29, 2018 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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