Cheap, Contactless Token Angle Sensor

Hi everyone,

I am working on a concept for a programming tool for primary aged students. The purpose of this post is to ensure I haven’t missed an obvious solution to the following problem:

The tool requires an array of sensors, which can be read sequentially, each senses the angular positions of a token (with a resolution of 8 possible positions for each sensor). The token will be constrained in its position, like a star shaped puzzle piece, with 8 positions possible.
It needs to be cheap (<$1ea), contactless, and reliable for the tool to be viable. There would be around 20 sensors.
(edit>) Each token would be around 40mm in diameter. (<edit)
Using an Arduino is also a requirement.

Currently I plan to use an LDR and LED pair. The token would be placed over a recess (shielding it from external light) an 1/8th segment would be open to the LDR, illuminated by the LED.
(edit>) The LDR would ‘read’ a shade, from black to white in 8 steps, from the exposed segment of the token. (<edit)
This would then be read in an analog matrix fashion.

From a few tests this seams viable. Alternatives I have considered include:

  • PixyCam (CMUcam5)
  • Hall Effect Sensors
  • 8 x Reed Switchs for each token
  • RFID…?

All of which seem either too expensive or more difficult to construct and implement.

The PixyCam would be the ideal solution, as it is future proof for the application. However, it is also 4 or 5 times the price of the LED & LDR array. The fast frame processing rate of the PixyCam is not required, a cheaper static or low frame rate version would work if one existed, the PixyCam interface would be nice though.

In closing, how would you tackle this problem? What is the best method? Have I missed something?

Thanks in advance,

You don't need 8 sensors - if you activate a suitable subset of the 8 positions only 3 detectors is needed to tell you the position. So if the illumination pattern is 00011101, and you have 3 consecutive sensors the 8
cyclic positions will read as 000, 001, 011, 111, 110, 101, 010, 100, which are 8 distinct patterns. You just
have to remap the values to consecutive integers with a table.

Thanks Mark,

I had concidered a binary type system, though having thought about it further, perhaps I ruled it out too soon.

I left out a part of the description of my current solution also.
Using the LDR & LED setup I plan to read a unique shade (from white to black in 8 steps) from the exposed segment. This would use a single sensor per token.

The same binary type setup would work for the reed switches, if that was what you were also implying. Though I am not sure this could be easily implemented. The tokens would need to be around 40mm in diameter. If reed switches came in a LED-like package (being actuated from above) and each token had an array of small neodymium magnets embedded in an encoder like patten with three seperate rings, totaling 12 magnets per token, then this would work. At this level of complexity and number of components I would likely be better off with a Hall effect rotation sensor, and a single magnet I believe.

Did I understand your solution correctly?

I'm trying to picture what you're describing, but fail. Can you post some drawings, or even images of the actual installation? That'll go a long way in understanding what you're trying to do.

I'm trying to picture what you're describing, but fail.

Me too !

Is this anything like correct:

a) You have a number (how many?) of 'Tokens', each about 40mm diameter which you want to detect.

b) A Token is placed in some sort of 'Holder' to be detected.

c) When a Token is placed in the Holder, it could be in any one of 8 orientations.

d) you want to know:
i) which Token it is
ii) what orientation the Token is in


That’s it TonyWilk. Except I don’t need to know which token, they are identical, only it’s orentation matters.

I’ll post an image later today.



I just realised I misunderstood and over complicated your solution. Clearly it needed more thought on my part.

So, 4 magnets arranged on the “1’s” of this the circular pattern: 00011101. Three sensors spaced one segment apart would then detect the pattern you described...

This would be much more reliable, for either the LDR or the reed setup.


So, 4 magnets arranged on the “1’s” of this the circular pattern: 00011101. Three sensors spaced one segment apart would then detect the pattern you described…

Neat !

However, I think you’d need 4 sensors, in the same pattern. 3 sensors gives you “000” … “111”

but you can’t distinguish “000” from no token at all


True TonyWilk,

I would need to be able to detect if a token was present.
Adding a fourth sensor could also give a few more detectable variations, I think. Which may be handy in the future.

So exploring this solution, what sensor would you use?

Something like a unipolar Hall effect Switch, like the US5881:

These are avalible for around $1.50ea, so $4.50 per token + magnets. This, I think would probably be the most reliable option and there are cheaper options available.

The custom LDR and LED combination, prehaps $2.00 per token. The cheapest option I can think of.

A Reflective IR Sensor like this one:

Around $2.00ea, so $4.00 per token.


Full credit to MarkT for the basis of this idea.

I like the idea of magnets and reed or Hall switches. Both the magnets and sensors can be completely covered / painted / whatever.

Reed switches can be cheap:

Mind you, just about anything's cheap from China/Hongkong:

Not too keen on the LDR / LED, reflective IR's not so bad

  • but ambient light or dirt can mess 'em up.


Images, please. Without being able to picture the actual thing it’s hard to suggest suitable sensors.

LDR+LED should be really cheap in parts. Last time I ordered LEDs they cost a few fen a piece, LDRs slightly more. So your whole setup would cost about RMB 2-4 in parts for ten such tokens when done with LDR & LED, or about 2.5-5 for my dollars (HK). Don’t know what version of $ you use. You’d still need reflectors on your token, and make sure it lines up very well to allow for the LED light to reach your LDR.

Magnetic is less critical but costs a little more; not so long ago I bought nice water proofed reed switches, they were some RMB5 a set, including the opposing magnet part, all in nice plastic housing and with screw holes for easy mounting. Meant to detect a door or window opening or so.

Hopefully this helps describe the setup, and current solution:

The black piece is the ‘token’ and can be removed, or repositioned in any of the 8 orientations. The star shape would hold the token in position, so alignment is reliable +/- ~2mm. The token is ~40mm in diameter, around its outer tips.

The table to the side describes the output of each of the 8 orientations, with a few combinations left over.

The window reed switches would be too big, though the small glass sensors I believe they contain would probably work. I believe they have a small range of alignment in which they function correctly, making assembly more difficult prehaps.

It is a shame they do not come in a more compact form. As mentioned above, a standard LED-type package would be ideal, pushing me more towards a Hall effect switch with a transistor-like package.

Untitled_Artwork.pdf (199 KB)

Neat !

However, I think you'd need 4 sensors, in the same pattern. 3 sensors gives you "000" .. "111"

but you can't distinguish "000" from no token at all


That's quite a good point! Yes.