Maris, I have been thinking of the same thing - in this case to enable the fuel pump in my car - push button once, car will go 3 minutes and then not again until you tap the correct code. Couple that with the fuel guage showing empty and you my trick a thief (hijacker?) into thinking the tank is empty. I have not gotten round to it yet (won't for a while), but I would suggest that you first implement it on a PC using your favourite high level language. That should teach you the in's and out's. I have done something similar on a PC to figure out the timing of music (can't remember at the moment why I would have wanted to do that). Basically, tap in the rythm, PC tells you 8th note, 16th note etc. I had limited success, partly due to the variability involved. A good start is probably expressing the tap durations as fractions of the duration of the longest tap in the sequence, and limiting yourself to two or three lengths of taps (say whole, half and quarter notes). That way the longest (or first) tap acts as a reference. Better still, make the first tap a half note, and use only whole and quarter notes in the rest of the sequence. That way, you measure the first tap, and then just decide if the subsequent taps are longer or shorter than the first one. Might make for a strange rythm though :-). Come to think of it, the half note could be any note in the sequence, since you can just wait for it and evaluate the sequence after it (the whole sequence) is entered. Other half notes in the sequence could just be wildcards - their duration doesn't matter, as long as they are present. Tap duration should be measured from the beginning of the tap to the beginning of the next tap, ie. including the spaces. Thus you could just look at falling edges if your normally open switch leaves the pin input high. Also debounce the switches etc. For learn mode, you'd have to tap in the rythm and tell it which tap acts as the reference (the pic could find a tap that has more or less half of the other taps longer than itself, and half the taps shorter). It would have to decide which taps are wildcards (have the same duration as the reference tap). This sort of thing is a lot easier if you can do divides - fractions close to one would indicate wildcards if you divided an arbitrary duration by the 'reference' duration. Have fun Roland -----Original Message----- From: Maris To: PICLIST@MITVMA.MIT.EDU Date: 06 April 1999 23:15 Subject: [PIC] Single-button combination lock project > I would like to make a PIC single-button "combination lock" for my >workshop door. This is not a high-security situation (the door is normally >unlocked), I just want to do it for fun and to learn something. > The way the lock would work is that you would push the button in some >rhythm such as that of "shave and a haircut, two bits". This is only an >example, any rhythm could be used. This and only this would activate the >solenoid lock. > One problem is that it would have to tolerate some human variation in >the rhythm, such as 5 or 10%. It should reset immediately if a bad rhythm >is entered and it should time out if the rhythm is not completed. A >desirable added function would be if the lock could operate in a "learn" >mode where you would enter the rhythm manually with the push button and it >would learn it. Accompanying beeps or notes would be a plus. > Any guidance, thoughts, directions or code snippets would be appreciated. > >Thanks, >Maris >