Wondered if anyone would be interested in making a project for me. I have an old ship's wheel and I want it to open a mag lock when turned in the correct sequence (eg. left half a turn, right a full turn, left 1.5 turns).
I have the wheel so if someone could write the code and walk me through the wiring step by step I might be able to do it. Alternatively if someone wanted to do the whole project and send it to me (UK) that would be great. I've no idea what these things cost but am happy to pay the going rate.
What modifications are you willing to make to the wheel?
Adding an encoder to the shaft would be necessary to know where the wheel is. That can either be a relative encoder or an absolute encoder.
A relative encoder will tell you how much the wheel has moved, but will have no way of knowing where 0 is.
An absolute encoder will know where 0 is.
Seems like a no-brainer as to which to choose, until you look at prices. A relative encoder can be had for a few $. An absolute encoder will be a couple of orders of magnitude more.
If the Arduino that the encoder is connected to is always powered, or the absolute position doesn't matter, a relative encoder will be fine.
You'd need to firm up the requirements some. Does the wheel have to be moved a certain amount in each direction within some time frame? Does moving the wheel too far reset things? What tolerance is there on the amount of the turn? That will have two effects - one on the kind of encoder (cheap --> expensive) and one on the code. The higher the accuracy requirements, the more expensive the encoder needed, and the more important to provide feedback (which is why safe dials have numbers on them).
If you are handy, you could build your own thingy to detect the position of the wheel - put some pins on the shaft to act as cams operating some microswitches.
Gray code for extra win. If you only care what quadrant the wheel is in, then two switches will be enough. Three will get you an octant.
The sketch would keep an array of the last N quadrants that it sensed the wheel in. When it senses that the wheel has moved to a new quadrant (with some debounce, of course), then everything gets shifted down by one and the new quadrant gets pushed onto the end of the array.
So if your code is "N, clockwise West, antiCW S, clockwise S, anti-CW N", then you record the quadrants that the wheel is in until the sequence matches
N E S W S W N E S E N
At which point - open.
as an alternative to this kind of absolute positioning with cams, you can use quadrature encoding to count the ticks and adopt the convention that if the wheel is motionless for more than 3 seconds, then whichever way it is now counts as being north. This is the same as using a relative rotary encoder.
Essentially, I'm suggesting that you can add cams and microswitches to the wheel shaft to build your own rotary encoder.
If you don't want to hack up the wheel, then perhaps use a rotary encoder with a wheel on the end, and rig that wheel up to run against the shaft with a spring to keep it in good contact.
Given the OPs suggested combination style - lefts and rights in different sizes, a relative encoder seems simplest. Assume that after some number of seconds of inaction (ten?) that the system is reset. Then look for movement and check against the combination.