15
\$\begingroup\$

I have a project that is essentially a pegboard with 4 different types of pegs. Each peg fits into every hole, but when one is inserted, I'd like to digitally record its type and position. There are a total of 120 pegs, 30 of each type. The board itself is a square grid, with at most 40mm between holes. The size and design of the pegs and holes hasn't been decided yet.

The simplest and cheapest idea I could come up with was a switch at the bottom of every hole and a separate input method to declare the type: eg. 4 buttons somewhere on the side, which you could push afterwards to tell the system that type A was just inserted. This has a large effect on the user interface, one I'd like to avoid.

I could design the hole to be asymmetrical, wire 4 switches to the bottom and have each peg have 4 prongs with one being longer than the others. That would mean soldering a lot of very tiny things together and a more delicate final product, though.

Cost is also an issue, as it's a hobby project.

Is there some sort of sensor I could use for this?

Edited to add: I should have probably said this to start off with, but I tried to slightly generalize the question to maybe make it more useful: the project is a board game. The idea is to have up to 4 players capture territory on a board and have the board itself handle all the necessary bookkeeping in real time.

\$\endgroup\$
  • 1
    \$\begingroup\$ One suggestion is the following: (1) "Load" the 4 types of peg with different weights, eg, Type 1 peg = 10 grams, Type 2 = 20 grams, (2) buy 102 cheapy weight sensors (US$5 for 5 pieces): aliexpress.com/i/32669458593.html, (3) put each sensor at the bottom of the hole, and connect it with a fixed value resistor to form a voltage divider. (4) Now when a peg is inserted, the weight changes resistance of the weight sensor and therefore the voltage of the voltage divider, (5) Arduino ADC pins can be used to measure the voltage and therefore know which type of peg is inserted. \$\endgroup\$ – tlfong01 Sep 29 at 8:57
  • 2
    \$\begingroup\$ PS, we don't need 120 Arduino ADC pins to measure 120 voltage signals. Usually we EE guys use a matrix keypad like to "scan" the keys to tell which key is pressed. Eg 12 x 12 I/O lines can scan 144 binary keys. But of course "weighted" analog keys/pegs might make my suggested design very complicated. But to us EE engineers, nothing is impossible. Instead of matrix scanning, we can also consider demux analog selectors connected to cheapy 8 channel MCP3008 ADC modules. Just brainstorming, cheers. \$\endgroup\$ – tlfong01 Sep 29 at 9:11
  • 5
    \$\begingroup\$ Analog synthesisers did this in the early 1970s ... possibly inheriting their plugboards from ENIAC-era computers. Look for "plugboards" and if you cat't find any, just buy a thousand jack sockets and make your own. Fit one of 4 different resistor values in each plug. \$\endgroup\$ – Brian Drummond Sep 29 at 13:05
  • 2
    \$\begingroup\$ What is the position of the board? Is it in horizontal position, as over a table, or vertically fixed in the wall? \$\endgroup\$ – mguima Sep 30 at 20:20
  • 1
    \$\begingroup\$ @mguima the original idea was horizontal, although now that I think about it, it should work both ways. \$\endgroup\$ – Celos Oct 1 at 7:54

12 Answers 12

31
\$\begingroup\$

Use a multi-pole jack plug.

enter image description here

Figure 1. Random 4-pole, 3.5 mm jack plugs from Wish.com.

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 2. Plugs can be encoded by shorting out the tip, ring 1, ring 2 to sleeve pins in a binary code pattern.

You can't use code 0 as this will be the same as no plug inserted. That leaves you with seven possibilities and you only need four. Colour-coding the plugs to indicate their numerical value seems a good idea to me.

schematic

simulate this circuit

Figure 3. Preventing cross-feeds. 1N4148 diodes should be small enough to fit two into a plug.

As pointed out by @A.I.Breveleri the addition of diodes in the plug allows the use of a keyboard scanning solution. In this type of arrangement the diodes prevent cross-feeds when multiple keys are pressed. The same arrangement would work here.

enter image description here

Figure 4. Keyboard matrix example. Image source: Gammon.com.

See the linked article for an explanation.

| improve this answer | |
\$\endgroup\$
  • 3
    \$\begingroup\$ Alternatively, use sockets with break contacts. This would allow you to detect when a plug is inserted, independently of its binary code. Then TRS plugs could be used to give a 2-bit code. It may come down to what is the cheapest option, given the number of plugs and sockets needed. \$\endgroup\$ – Simon B Sep 29 at 9:35
  • 7
    \$\begingroup\$ Or use a mono one with different resistors... \$\endgroup\$ – Chris Stratton Sep 29 at 21:28
  • 2
    \$\begingroup\$ I had considered that but that means a load of ADC work. This solution is purely digital. \$\endgroup\$ – Transistor Sep 29 at 21:38
  • 3
    \$\begingroup\$ Finding enough ADC inputs for one side of a matrix isn't hard, and they don't have to be good ADCs, just able to distinguish 0/1K/10K/100K... capacitor RC time constant could work. \$\endgroup\$ – Chris Stratton Sep 29 at 21:42
  • 7
    \$\begingroup\$ While this is a great idea, note that the plug will intermittently short out various combinations of contacts during insertion and removal, so there needs to be a mechanism to filter this out. With some luck (depending on the internal design of the sockets used), one can perhaps use the tip and sleeve for insertion sensing and only rely on the two rings for the one-of-four identification. \$\endgroup\$ – TooTea Sep 30 at 15:40
26
\$\begingroup\$

Use a two-contact plug like a 3.5mm mono TR (tip-ring), or a 6.5mm if you have the space and prefer a slightly easier-to-handle peg. Connect different resistor values between the tip and ring in each plug, and set up voltage dividers going through each jack in the pegboard, connected to an MCU's ADC pin through multiplexers.

With, for example, fixed 10K resistors in the dividers, and 0 ohm, 5.1K ohm, 15K ohm, and 91K ohm options in the plugs, you'd get roughly 0.0, 0.3, 0.6, or 0.9 of the reference voltage at the ADC pin, which should be easy for the MCU to distinguish.

This doesn't require any particular orientation of the plug, unlike mechanical and optical solutions. You can use off-the-shelf plugs and jacks. On the down side, it takes a fair amount of force to insert and extract the plugs.

The biggest challenge is designing the multiplexing circuit to allow all the jacks to be scanned from a single controller.

grahamj42 suggests:

How about using 1-4 diodes in series in the plugs and detecting the voltage drop? You could then do away with diodes in the matrix.

This would work also. With a 3.3V ref ADC, and diodes with 0.7V drop, you'd see 2.6, 1.9, 1.2, and 0.5V, with each step being nearly 20% of full-scale. There would be more total parts even including the savings in the matrix, though: 300 diodes instead of 150 resistors + 120 diodes (assuming 120 holes in the board.)

| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ Indeed. And use the bigger old 1/4 inch plugs for durability and ease of wiring. Of all the ideas floated, I think this one is the most readily made practical in the sense that it can be designed and proven on a small scale and then it's just a matter of buying more parts and wiring up the big board. \$\endgroup\$ – Chris Stratton Sep 30 at 5:36
  • 2
    \$\begingroup\$ The muxing isn't really complicated, many MCU's have enough distinct ADC inputs to read all of the column lines, and you just (slowly) drive the row lines one at a time. Just as with a keyboard, each cell/socket needs a diode. \$\endgroup\$ – Chris Stratton Sep 30 at 5:46
  • 1
    \$\begingroup\$ I vaguely seem to remember that one of the UK electronics magazines from the mid-to-late 70s had a project involving different-valued resistors inside 3.5mm plugs. \$\endgroup\$ – TripeHound Sep 30 at 6:05
  • 2
    \$\begingroup\$ How about using 1-4 diodes in series in the plugs and detecting the voltage drop? You could then do away with diodes in the matrix. \$\endgroup\$ – grahamj42 Sep 30 at 17:56
  • 3
    \$\begingroup\$ I'd much rather have some diodes on the main board of my project than try to cram multiple diodes into the shell of a jack plug (even a 1/4 inch one) \$\endgroup\$ – Peter Green Sep 30 at 18:31
13
\$\begingroup\$

I expect the cheapest option is to point mobile phone you already own at the board and use coloured pegs along with writing some image processing software.

And as the phone is a "sensor", I think this solution keeps to the spec.

| improve this answer | |
\$\endgroup\$
  • 6
    \$\begingroup\$ What times do we live in when a mobile phone camera is the "simpler" solution compared to wiring a few jack plugs ... :) \$\endgroup\$ – Hagen von Eitzen Oct 1 at 20:04
  • \$\begingroup\$ @HagenvonEitzen, it then needs a CPU etc to scan the jack plugs hence needing hardware and software skills compared to just needing software skills. \$\endgroup\$ – Ian Ringrose Oct 2 at 16:24
8
\$\begingroup\$

One suggestion is the following, using the smart pegboard below as an example illustration:

smart pegboard

(1) "Load" the 4 types of peg with different weights, eg, Type 1 peg = 10 grams, Type 2 = 20 grams,

(2) Buy 102 cheapy weight sensors (US$5 for 5 pieces, see Appendix A below for more details),

pressure sensor

(3) Put each sensor at the bottom of the hole, and connect it with a fixed value resistor to form a voltage divider.

(4) Now when a peg is inserted, the weight changes resistance of the weight sensor and therefore the voltage of the voltage divider,

(5) Arduino ADC pins can be used to measure the voltage and therefore know which type of peg is inserted.

(6) To determine the position of the peg, there are many method, as briefly described below:

(6.1) Matrix keypad with keys pressed or released

The common method is to use 12 x 12 GPIO pins wired as a matrix. As soon as a key is pressed, Arduino will be notified. Arduino will "scan" the keys row by row, and if the row with a key pressed, Arduino will then scan the keys.

(6.2) Matrix keypad with keys pressed with different pressure levels

The approach is similar to the digital on/off keypad above. But now the Arduino uses its ADC (Analog to Digital Conversion) pins to measure the pressure level of the keys.

(7) Combinations of matrix keypad and multiplexed ADC devices

Since Arduino or Raspberry do not have enough GPIO/ADC pins to go around, we can use 16 channel GPIO expanders. Two MCP23017 can make a 16 x 16 matrix and so can scan up to 256 keys.

Arduino's ADC pin is only 8 bit resolution. If using 10/12/16/24 bit resolution ADCs (evan a 10 bit ADC can detect 2^10 = 1024 values or 0.1%), it is easy to differentiate among pegs with as little as less than 1 gram difference. So if 120 pegs have unique weights differ by small quantity not noticeable by humans, Arduino can actually tell which one of the 120 holes/pegs is inserted (but of course in this case it is which hole, not which peg we need to know.

(8) Combination of ADC and Analog multiplexors.

Popular but cheap 10/12/16 bit ADCs such as MCP3008, MCP3208, ADS1115 has 8 channels. There are also unidirectional/bidirectional analog multiplexors to make the matrix wiring much simplified


References

(1) High Accuracy Resistive Weighing/Pressure Sensor - US$3.15 (5 pieces)

(2) A Futuristic Pegboard, Turns Boring Rehab Into a Game - Rapael,2018jan17

(3) Smart Pegboard Video - Rapael,2018jan17

(4) A peg board with 24 colorful cylinder pegs and removable inner pegs helps children with perceptual motor development and finger dexterity.

(5) Haljia 5Pcs BX120-3AA High Precision Resistance Strain Gage Strain Gauge GAGE Full Bridge Used for Pressure Weighing Sensor

(6) Adafruit TCS34725 RGB Sensor Demo - 2018mar25

(7) Adafruit Color Sensors

(8) AliExpress Hall Effect IC and Module Catalog (A3144E, SS49E etc)

(9) AliExpress Tiny Magnets Catalog

(10) SS49e Magnetoresistive Linear Hall Effect Sensor Datasheet - Honeywell

(11) Allegro A3144 Datasheet

(12) TCS230 TCS3200 Color recognition module Color sensor module - US$4.6

(13) MCP3008/MCP3208 10/12 bit ADC Testing and Programming - EESE, tlfong01


Appendices

Appendix A - Pressor Sensor Spec

HALJIA 5Pcs BX120-3AA High Precision Resistance Strain Gage Strain Gauge GAGE Full Bridge Used for Pressure Weighing Sensor

pressure sensor

Price: £6.99 (£1.40 / Item)

Made of constantan foil, fully enclosed structure.

Temperature self-compensation and creep self-compensation can be realized simultaneously.

The strain gauge is attached to the measured object to make it expand with the strain of the measured object, so that the metal foil inside the strain gauge can extend or shorten with the strain.

The resistance of many metals changes when they are mechanically elongated or shortened. The strain gauge is used to measure the strain by measuring the change of resistance.

In general, the sensitive grid of strain gauge is made of copper-chromium alloy, whose resistance variation rate is constant and proportional to strain.

Specifications for this item Brand Name HALJIA Item Weight 5.00 grams

Feature:

Made of constantan foil, fully enclosed structure.

Temperature self-compensation and creep self-compensation can be realized simultaneously.

The strain gauge is attached to the measured object to make it expand with the strain of the measured object, so that the metal foil inside the strain gauge can extend or shorten with the strain.

The resistance of many metals changes when they are mechanically elongated or shortened. The strain gauge is used to measure the strain by measuring the change of resistance.

In general, the sensitive grid of strain gauge is made of copper-chromium alloy, whose resistance variation rate is constant and proportional to strain.

Resistance Value(Ω): 1002Ω ± 0.1

Sensitivity Coefficient: 2.0±1%

Base Dimension: 7.3mm x 4mm x 1mm

Wire Grid Dimension: 3*3.1mm

Room Temperature Strain Limit: 20000um/m

Room Temperature Insulation Resistance: 10000MΩ

Backing Material: Modified Phenolic


Appendix B - Hall Effect Sensors and Tiny Magnets Specification

(1) AliExpress Hall Effect IC and Module Catalog (A3144E, SS49E etc)

(2) AliExpress Tiny Magnets Catalog

a3144 1

ss49e


Appendix C - Using MCP3008/MCP3201/MCP3208 ADC to measure weight sensor and magnetic sensor output

MCP3008/MCP3208 10/12 bit ADC Testing and Programming - EESE, tlfong01

Arduino's 8 bit ADC pins might not be accurate to do ADC. Rpi has no ADC pins. So either way you need to use ADC chips/modules.

For this project's weight and magnetic sensor, I think 10/12 bit resolution (< 0.1%) is more than enough. For newbies, I usually recommend MCP3008/MCP3208 which is very popular and you can find through hole chip to play with bread board.

You might like to read my answer linked above to get a rough idea of how the ADC works, and if you are OK with python, try my demo program, fully debugged, just copy, paste, and run, without need to use any libraries. Or you can search for drivers that fits your computer.


| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ +1 for the thoroughly well documented answer, and for talking about those cheap weight sensors that I didn't know but now I'm going to order a batch just to play with. I'm afraid that the proposed solution needs a board in horizontal position, I don't know if OP wants to fix the board in the wall. \$\endgroup\$ – mguima Sep 30 at 20:24
  • \$\begingroup\$ Well, when I read the OP's question, I noticed that he uses the word "bottom". In my mother tongue, "bottom" usually, but not always, is relative to the top. So my instinct was that the peg must be in up right position. I did notice that every one else is assuming the pegboard is sort of hanging a wall. Actually I have never met this word "pegboard“ in my life. I vaguely remember I once read about using a hammer to hit a wooden peg into the ground, when setting up a tent in a country side. I did have a couple of other suggestions, but / to continue, ... \$\endgroup\$ – tlfong01 Oct 1 at 6:58
  • \$\begingroup\$ those need to know more than Ohm's Law and voltage divider, and the sensors are a little bit more expensive, about US$4 each peg. I hesitate to suggest that which can use peg boards fixed in any orientation, horizontal or vertical, top down or bottom up (yes, pegs won't fall down), actually even floating in the air, like inside a spaceship where everything dead or alive, is floating in the air. But because I usually try it out first before telling it. Anyway, I think I first experiment and then report back. Stay tuned, ... Cheers. \$\endgroup\$ – tlfong01 Oct 1 at 7:07
  • 1
    \$\begingroup\$ @tlfong01, I clarified the project in the question, but you were spot on with your assumptions. Thank you very much for taking the time to research and answer this! \$\endgroup\$ – Celos Oct 1 at 8:07
  • \$\begingroup\$ @Celos. Thank you for your clarification. So it is sort of a board game, and the peg board is placed one table. Perhaps you might also like to let us know if you have any preferred requirements on the pegs, say (made of wood, or paper can also do, not more than 5cm tall, and hole not more than 4cm deep etc. Of course we don't allow any wireless electronic stuff hidden inside the peg. Earlier I suggest to load the pegs with weights. My other suggestions uses tiny magnets, one tiny magnet insert in green peg, two stacked up magnets for blue magnet, and so on, \$\endgroup\$ – tlfong01 Oct 1 at 8:20
6
\$\begingroup\$

Make the 4 kinds of pegs out of different colors of clear plastic, say red, green, blue, and yellow.

At the bottom of each hole, mount a white LED that shines through the peg (or empty space) and frost the other side so that the light diffuses through the case.

Sprinkle a few red, green, and blue sensors around inside the case.

Have an arduino rapidly light each hole in turn using row/column addressing, and use an A/D on the sensors to determine what color of peg the light is shining through.

This way, the only thing you have to do 120 times is cut a rod to make a peg, and the soldering is not so bad using row/column addressing. Just make sure you put the resistors on the row or column lines so you don't need a separate one per LED.

You may need a demultiplexer if you don't have enough individual pins for the rows and columns.

| improve this answer | |
\$\endgroup\$
5
\$\begingroup\$

the project is a board game. The idea is to have up to 4 players capture territory on a board and have the board itself handle all the necessary bookkeeping in real time.

enter image description here

Figure 1. One project that might give some ideas. Source: Bergers Projects.

To compliment my jack-plug answer, this problem has been solved by electronic chess boards. Each piece has a magnet in its base to activate reed switches on the board. The pieces are placed in the standard starting positions and only one piece is moved at a time. The controller just has to keep track of whose turn it is, which piece has been picked up and where it has been put down. (I guess most of these systems can't even tell the difference between the piece colours, never mind their character.)

Whether this would work for you or not depends on the rules of the game and the discipline of the players.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Nice idea and example. I actually thought of handling this in software, but the game has a simultanious action phase, so no real way of keeping track of turns. These answers have given me an idea of converting a different game, though. I might start with that as a bit of a warm-up. \$\endgroup\$ – Celos Oct 5 at 7:51
4
\$\begingroup\$

It would take some serious engineering, but I bet you could do some sort of matrix scheme where each of the X and Y wires had a few turns coil wound around each peg socket, and the pegs had a core made of ferrite of different permitivity.

It wouldn't be too hard with a dedicated circuit per hole, the challenge would be making it work as a matrix. Possibly you could do something with a distinct circuit for the AC inductance measurement capacitor coupled to each cell, and then have the matrix drive diode switches to cut off all but one cell at a time?

Or build effectively magnetic core memory, but make the pegs be of different coercivity and test to see how hard you have to drive them to get them to flip.

That said, while the idea of avoiding a dependence on electrical contact is quite enticing, getting one of these schemes to work at all is going to be a lot more effort than a phone plug type solution which could be soundly proven in an hour or two and then scaled up. This would be more like a "new improved version 2.0" to be pursued only in the shadow of a "safe" contact design.

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

There are a total of 120 pegs, 30 of each type

That means there are four different peg designs so think of them like a key that goes in a lock and design the 4 different pegs to have 4 different physical profiles just like a door key but simpler.

You might use transparent coloured pegs and use light to determine the peg's colour. So each hole would need a white LED emitter and an RGB photodiode circuit. Or you might decide to make the peg grooved; one groove is the fattest and is used to force the user to place the peg in the correct orientation (the reference angle). It would have another groove that could push on a microswitch. This second groove's position would be different for each peg design.

Or you could have notches arranged as a two-bit number (representing 4 values) and use light detectors to read the 2-bit binary value of the peg.

Just a few thoughts.

| improve this answer | |
\$\endgroup\$
3
\$\begingroup\$

Inspired by the other answers I came up with this. It works on the principle that different coloured LEDs have different voltages at the same current.

To detect a peg electrically, you need reliable spring contacts, so use simple two terminal jacks and plugs, such as 1/4 inch phone type. To each plug solder an LED of one of four colours, each colour corresponding to one of the four types of peg.

Then the jacks are arranged in a grid, so that when the pegs are inserted the circuit is arranged in the following manner:

enter image description here

Assume there is a jack at each intersection, and each colour LED implies a different type of peg.

Each column of the grid is supplied by an adjustable linear regulator configured as a constant current source.

To detect and identify the LEDs in the top row, you would bring D2 and leave D1 as high impedance. Then measure the voltage at A1 and A2 using the analogue inputs of a microcontroller. A1 will have a voltage corresponding to a red LED and A2 will have a voltage corresponding to a green LED. If a jack is empty, you will get the open circuit voltage of the regulator circuit.

If you scan the grid fast enough, each LED will appear to glow steadily, identifying the pegs to the players while providing an interesting visual effect.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Interesting idea, but you don't necessarily need the constant current source vs. a resistor and it's not necessarily clear that even a constant current would get the same apparent brightness out of different LED types. What would be interesting would be after doing the detection to then leave the LED on for a color-dependent amount of time in an effort to equalize the apparent brightness. \$\endgroup\$ – Chris Stratton Oct 2 at 19:35
  • 1
    \$\begingroup\$ You might also find that the minimum voltage drop of the LM317 and resistor won't leave enough voltage for the LEDs - particularly the blue. \$\endgroup\$ – Transistor Oct 2 at 20:59
  • 1
    \$\begingroup\$ @ChrisStratton Using a resistor would reduce the measurable voltage difference between colours, as the longer wavelength LEDs would get substantially more current, but I agree it would probably still work. The shortest wavelengths might end up quite dim, especially as the eye isn't that sensitive to blue compared to green. I like your idea of controlling the brightness. \$\endgroup\$ – William Oct 3 at 13:34
  • 1
    \$\begingroup\$ @Transistor 3.3V for a blue LED + 120Ω x 10mA for the resistor is 4.8V, so a higher supply voltage than I've drawn would be required. Further, we may want a higher current to account for the low duty cycle. \$\endgroup\$ – William Oct 3 at 13:49
3
\$\begingroup\$

The most basic solution that comes to my mind is to put 2 spring contacts at the bottom of each hole – one close to the side and another close to the center –, make a small PCB with 2 circular pads with resistor between them and attach it to pegs underside.

When peg is inserted into hole, it will short the gap with its resistor and increase voltage level across voltage divider according to the type of inserted peg. If MCU's ADC's resolution allows it, you can even connect several holes in series, adding correct bypass resistors between hole contacts, and scan them at once to improve speed and reduce amount of wiring. 200-500 uA of current should be enough for detection purposes, thus, entire setup shouldn't consume more than 20 mA in scan mode, allowing to run project from batteries.

This would require some surface-mounted spring contacts (like this: https://www.te.com/global-en/product-2329497-2.datasheet.pdf), 2 pieces of small PCB, 2 resistors and some glue to fix PCBs to undersides of pegs and bottoms of the holes. Should be inexpensive and easy to assemble.

The only downside I can see already, is that it's hardly dust-proof. I believe this problem can be alleviated by making "pegs" bell shaped, putting PCB with spring contacts inside them and redesigning "holes" as pegs with conductive pads on board. Think, LEGO board as base and small 1x1 blocks on top as pegs, so it is peg board with 4 types of cups.

For STM32 with 12 bit ADC, it will need 240 spring contacts, about 300 SMD resistors (0805 pretty okay, 1208 easier to hand-solder), 240 small (round) PCBs (2-3 cm in diameter), 5 8-bit shift registers, 20 supply and 40 sensing connections to the board sensor matrix. Should be about 100$ for everything electrical plus whatever else must be added as user interface.

Finally, cost can be further reduces by replacing spring contacts with solder beads, but contact reliability will be lower.

| improve this answer | |
\$\endgroup\$
1
\$\begingroup\$

How about having the sides of the pegs have serrations that actuate a microswitch multiple times according to its colour? As the peg is inserted all the way, the switch will be rapidly clicked. One click for red, two for blue, etc. You just count the number of consecutive clicks from that microswitch. Keeps the electronics and mechanics pretty simple but moves the burden to software, though that's a simple problem to solve even with the most basic of microcontrollers.

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ Switch contacts tends to bounce a bit, so sampling rate would be pretty high for pegboard with 120 holes. Also, what would happen if player moves peg back and forth few times without going fully inside, how MCU supposed to know if switches click on way in or on the way out? \$\endgroup\$ – weaknespase Oct 15 at 20:08
  • \$\begingroup\$ @weaknespase You can do debouncing in software, and you only need to sample a specific peg hole at a high rate once you detect a click there. Or you can use an optical sensor and have barcode-like markings printed on it. And you can have the last serrations end in a depressed state to indicate full insertion. If the end state of the switch isn't depressed, either the peg wasn't fully inserted or it was pulled back out. \$\endgroup\$ – Allon Guralnek Oct 16 at 23:15
  • \$\begingroup\$ One switch can't guarantee that, because user can move peg back a bit before going fully in, registering one or more erroneous clicks at the end. Having second switch at a small (less than width of nub) offset will help to distinguish movement direction by looking at order of actuation. \$\endgroup\$ – weaknespase Oct 18 at 12:32
  • \$\begingroup\$ @weaknespase One switch can guarantee it because if you don't detect a depressed state within a certain time limit, you ignore the clicks. Assuming you use a nub at the end of the peg to hold the microswitch down after the serrations, a correct insertion of three clicks would be .....10..10..10..1...... whereas a partial insertion would be ....10..10........ If it doesn't end in 1 then as a resting state (say min 1000ms) it hasn't been fully inserted. When removing a peg the resting state will always be 0 so you can immediately assume the peg was removed. \$\endgroup\$ – Allon Guralnek Oct 19 at 3:39
1
\$\begingroup\$

One idea that's sort of a variant of the "point a phone camera at the board" answer would be to have a single camera underneath the board, in such a way that each peg is visible to the camera as its inserted.

Pros:

  • a single camera is probably cheaper than most of the "price per hole" answers already proposed
  • you control the hardware end-to-end, so you can probably make the software that "reads" the peg positions a little more easily than writing a mobile app

Cons:

  • This might push the board height up quite a bit to get all the holes in frame for the camera
  • lighting might also be an issue
| improve this answer | |
\$\endgroup\$
  • 2
    \$\begingroup\$ Optical fiber can be used to create pathway from hole to the camera in question to avoid raising the board. Translucent pegs can be colored, hole bottoms transparent and chamber with camera darkened to make effective use of ambient lighting, I think. \$\endgroup\$ – weaknespase Oct 15 at 20:13
  • \$\begingroup\$ Heh. As with a lot of these solutions... that sounds expensive to me in terms of component costs! (Cool, but expensive!) \$\endgroup\$ – livingtech Oct 16 at 22:51
  • 1
    \$\begingroup\$ I don't think it is as expensive as it seems. Fiber optics are cheap, transparent acrylic sheets are cheap, camera is not necessary since we only need to read color and can be replaced by rotating prism with inexpensive RGB color sensor. Essentially it'll be somewhat fancier (color!) linear barcode reader. \$\endgroup\$ – weaknespase Oct 18 at 12:47

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.