binary password lock.
' {$STAMP BS2} ' {$PBASIC 2.5} INPUT 0 INPUT 1 INPUT 2 INPUT 3 'HIGH 15 'PAUSE 2000 'LOW 15 no1 VAR Byte no2 VAR Byte no3 VAR Byte no4 VAR Byte pw1 VAR Bit pw2 VAR Bit pw3 VAR Bit pw4 VAR Bit digit VAR Nib DO IF (IN0 = 1) THEN no1 = 1 ELSE no1 = 0 ENDIF IF (IN1 = 1) THEN no2 = 2 ELSE no2 = 0 ENDIF IF (IN2 = 1) THEN no3 = 4 ELSE no3 = 0 ENDIF IF (IN3 = 1) THEN no4 = 8 ELSE no4 = 0 ENDIF digit = no1 + no2 + no3 + no4 IF (digit > 0) THEN DEBUG DEC digit, CR ENDIF IF (digit = 1) THEN pw1 = 1 ELSE pw1 = 0 pw2 = 0 pw3 = 0 pw4 = 0 ENDIF IF (digit = 2 AND pw1 = 1) THEN pw2 = 1 ELSE pw1 = 0 pw2 = 0 pw3 = 0 pw4 = 0 ENDIF IF (digit = 3 AND pw2 = 1) THEN pw3 = 1 ELSE pw1 = 0 pw2 = 0 pw3 = 0 pw4 = 0 ENDIF IF (digit = 4 AND pw3 = 1) THEN pw4 = 1 ELSE pw1 = 0 pw2 = 0 pw3 = 0 pw4 = 0 ENDIF IF (pw4 = 1 AND digit = 12) THEN HIGH 15 PAUSE 1000 LOW 15 pw1 = 0 pw2 = 0 pw3 = 0 pw4 = 0 ENDIF LOOP
I really need to tidy up this code. I have a really noobish way of the password lock. This is wired to a DTMF decoder outputting in binary. I need help making the DATA and READ commands to make a password lock. I have seen examples but I cant put them to my use. Brain overload. Somebody please help me to make this code more simple with a
password DATA "1, 2, 3, 4
at the start.
If anyone knows what I am talking about and can help please do

Thanks heaps
Microman171
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
- pins 0-3 are inputs where a binary password is "entered"
- input password is compared with password(s) in list
- if there is match, make pin 15 high for 1 second
- otherwise try again with input password
The only thing I wasn't sure of is that I *think* you are not allowing %0000 to be a password, so you could check for that before entering the do loop. Up to you.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 1/24/2008 12:39:08 AM GMT
Thanks again
Dan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Thanks for the help!!
Dan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
the password would be 4 sets of 4-bit binary outputted onto 0 - 3. This is actually going to be my science fair project. A cell phone controlled door latch. You ring up the phone connected to the BS2 and dial the code over the line. Each tone is converted to 4-bit binary. The BS2 need to be able to read each digit and check if they match the password/s stored in the BS2.
You help is greatly appreciated
Dan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
INA 1st time - bits 12..15 (digit 4)
INA 2nd time - bits 8..11 (digit 3)
INA 3rd time - bits 4..7 (digit 2)
INA 4th time - bits 0..3 (digit 1)
Since the "good" passwords are also stored as BCD, e.g., $4321, then you can just match pw to inPw as above.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Greatly appreciated
Dan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
0
0
0
2
2
2
2
2
2
2
0
0
0
0
0
3
3
3
3
3
3
0
0
0
0
0
0
0
0
0
4
4
4
4
4
4
4
light
0
0
0
0
0
0
0
0
0
0
0
0
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10
This takes care of infinite 0's. But what you would need to is add a counter in -- if 4 digits are received, then check.
No, if you counted 0 through 3 then it *would* be backward.... it's like this:
If I type $4 first, really that's the MOST SIGNIFICANT digit -- which would be NIB3 (the highest four bits of the pw). Humans *read* digits most-significant to least-significant; but if you are INDEXING digits, 0 is the LEAST significant. Try it with a debug and see:
Here's my earlier code with a digit counter. If it were me, I would put in another counter to *roughly* time things. If you don't get 4 digits in 30000 ticks or some such number, reset the digit counter (otherwise the Stamp could wait years for the 4 digit).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 1/25/2008 4:54:54 AM GMT
[noparse]:D[/noparse]
Dan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
1 + 1 = 10 Base 2
2 + 2 = 10 Base 4
3 + 3 = 10 Base 6
4 + 4 = 10 Base 8
5 + 5 = 10 Base 10