Making a code lock

Oct 10, 2011 at 3:14pm

Making a code lock

Hi i want to create a code lock in max 5, and I want to use a counter to keep track of what number and in what order i pressed them, how can I do this?

#59239
Oct 10, 2011 at 5:42pm

What do you mean by “code lock?”

#212850
Oct 10, 2011 at 6:32pm

Hi,

if by ‘code lock’ you mean a mutex/semaphore like approach, I’m just building a generic [mutex] external that will be included in the next release of The sadam Library. But you’ll need to wait a little bit for that (I’m hoping to launch the next release in a month, but as I’m doing it in my spare time, I can’t make a promise). The basic idea is that you’ll have many instances of the same object sharing the same name (like with coll, buffer etc.), and you’ll be able to lock/unlock them all at the same time.

HTH,
Ádám

#212851
Oct 10, 2011 at 7:28pm

Sounds like OP is just looking for a passcode.

andenn91: This isn’t secure, but will perform the way you describe:

– Pasted Max Patch, click to expand. –
#212852
Oct 11, 2011 at 6:44am

its a school project where im supposed to do a code lock that have a 4 digit code, and i have to press the code in correct order to unlock, and if i press the wrong order or a wrong digit it will reset, and I’m supposed to use a counter to keep track of what order i pressed :)

#212853
Oct 11, 2011 at 6:47am
– Pasted Max Patch, click to expand. –
#212854
Oct 11, 2011 at 7:18am

[zl] is your friend, no, with [zl stream] and [zl compare] you don’t need a counter

#212855
Oct 11, 2011 at 7:27am

some example how to use it?

#212856
Oct 11, 2011 at 7:30am

no, do your homework :-) (aka read the helpfile)

#212857
Oct 11, 2011 at 7:32am

i´ve tried for 24 hours now, i have to hand it in soon :/

#212858
Oct 11, 2011 at 9:03am

What elements do you need for the password thing?

1) Something to recognise what keys you have pressed and in which order
2) Something that compares what keys you pressed to what keys you are supposed to have pressed.

You can use a combination of [counter], [pack], [coll] and [if], which is what I assume you have been tasked to do – but there are much simpler (and more flexible) ways using objects which you might not have covered in your class yet, involving [textedit] or [zl stream] and [zl compare].

Put your mind down to use – it’s only an exercise, if you couldn’t do it on time, tell the teacher and he will help you, it’s not a crime!

#212859
Oct 11, 2011 at 1:01pm

If you were up front about it being a school assignment, we could have helped point you in the right direction earlier and helped described the correct approach. I can’t speak for everyone but if you think I would just hand over the code that finishes your homework for you, you are sadly mistaken. Better to ask the teacher BEFORE the deadline if he/she can be of more help.

The post above this one has a lot of helpful techniques. Basically in order to do this, you are asked to keep track of what’s been pushed. Using an object like table or pack and route will let you take the number from the counter (the order or index) and pack it to a list with the number of the key you pushed. Route could then help you separate out the numbers (according to index) and then test them.

The trigger object is also your friend, it will help you with the “reset if incorrect” part of the problem.

#212860

You must be logged in to reply to this topic.