'------------------------------------- ' ! D E M O P R O G R A M ! '------------------------------------- ' Code is consisted of 4 digits. ' 1 user code is entered in program. ' File:codelcd-D1.bas you can download on: ' http://www.avr.4mg.com/custom3.html '------------------------------------- ' Professional version: ' Code is consisted of 1 to 9 digits. ' File:code30.hex ' 1 master and 30(60) user codes. ' Current in stand-by is 4 mA. '------------------------------------- '------------------------------------- 'Project: CodeLockAVR - LCD ' File:codelcd-D1.bas 'Copyright: Kripa PURI 'WWW: www.avr.4mg.com 'Device: Atmel AVR uC 'Date: 5.2.2007 '------------------------------------- $regfile = "2313def.dat" $crystal = 4000000 Dim Keyread As Byte Dim Key As Byte Dim Code As Word Dim Mycode As Word Dim Digits As Byte Dim Point As Byte Ddrd = 255 Portd = 0 Relay Alias Portd.4 Beep Alias Portd.3 Config Kbd = Portb , Debounce = 40 Config Lcd = 16 * 2 'Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 'Enable = Portd.6 , Rs = Portd.5 '------------------------------------- 'Standard LCD 2x16; type:CMC216x01 or sim.; www.cct.com.my 'pin1: Ground(-) 'pin2: Supply(+) 'pin3: Supply(0V-5V DC) for LCD Contrast Level 'pin4: RS Signal 'pin5: R/W Selection 'pin6: Enable Signal 'pin7: Db0 (Data Bus Line) 'pin8: Db1 (Data Bus Line) 'pin9: Db2 (Data Bus Line) 'pin10: Db3 (Data Bus Line) 'pin11: Db4 (Data Bus Line) 'pin12: Db5 (Data Bus Line) 'pin13: Db6 (Data Bus Line) 'pin14: Db7 (Data Bus Line) 'pin15: Backlight Ground(-) 'pin16: Backlight Supply(+) '------------------------------------- '------------------------------------- Mycode = 5060 '------------------------------------- Do Cls Cursor Off Noblink Lcd "WWW.AVR.4MG.COM" Wait 2 Lowerline Lcd "CodeLockAVRdemo" Wait 4 Cls Set Beep Waitms 100 Reset Beep Waitms 100 Begin: Code = 0 Digits = 0 Point = 0 Scan: Cls Lcd " Enter code" Do Keyread = Getkbd() If Keyread <> 16 Then Gosub Gotkey Waitms 100 If Digits = 4 Then If Code = Mycode Then Goto Opendoor Else Goto Error End If End If Loop Loop Gotkey: Ddrb = 255 Set Beep Waitms 100 Reset Beep Waitms 100 Key = Lookup(keyread , Dta) Incr Digits Point = Digits + 6 Locate 2 , Point Lcd "*" Code = Code * 10 Code = Code + Key Return Dta: Data 12 , 9 , 6 , 3 , 0 , 8 , 5 , 2 , 11 , 7 , 4 , 1 Error: Cls Lcd " Code wrong" Waitms 100 Set Beep Wait 3 Reset Beep Wait 20 Goto Begin Ok: Waitms 100 Set Beep Waitms 200 Reset Beep Waitms 200 Set Beep Waitms 200 Reset Beep Return Opendoor: Cls Lcd " Code accepted" Gosub Ok Lowerline Lcd " Unlocked" Waitms 300 Set Relay Wait 1 Reset Relay Wait 1 Goto Begin