'***************************************************** '* Description : Olimex AVR-MT Pass Key Program '* Compiler : BASCOM-AVR 1.11.8.7.001 '* Date : Jan 24, 2008 '* mC : ATtiny2313 '* Author : popsci.com '***************************************************** $regfile = "2313def.dat" $crystal = 10000000 'Setup LED/Relay PD.3 for output Ddrd = &B11110000 'Setup LCD Config Lcdpin = Pin , Db4 = Portb.0 , Db5 = Portb.1 , Db6 = Portb.2 , Db7 = Portb.3 , E = Portd.6 , Rs = Portd.4 Dim A As Byte 'Dimensions of LCD Config Lcd = 16 * 2 'Setup Buttons Variable Dim Button As Bit Dim Displayflag As Bit Dim I As Byte Dim Randomi As Word Dim Password As String * 16 '* Main AVR-MT Program 'Light LED Set Portd.3 Gosub Menu 'Button Loop 'Determine Each Button State '6 Buttons: B1-B6; 3 Ports: PB5-PB7 Do 'Use Button 5 for saving your passwords to EEPROM 'Use Button 3 for saving your passwords to a PC via RS-232C serial port ' Ddrb = &B10001111 ' Set Portb.7 ' Reset Portb.5 ' Button = Pinb.5 ' If Button = 1 Then ' Cls ' Lcd "Button 3" ' End If ' Button = Pinb.6 ' If Button = 1 Then ' Cls ' Lcd "Button 5" ' End If Ddrb = &B01001111 Set Portb.6 ' Reset Portb.7 Button = Pinb.5 If Button = 1 Then Cls Password = "" Lcd "Your Password:" For I = 1 To 16 Randomi = Rnd(127) If Randomi < 33 Then Randomi = Randomi + 33 Password = Password + Chr(randomi) Next Lowerline Lcd Password End If ' Button = Pinb.7 ' If Button = 1 Then ' Cls ' Lcd "Button 2" ' End If Ddrb = &B00101111 Set Portb.5 Reset Portb.6 Button = Pinb.6 If Button = 1 Then 'Turn ON LCD If Displayflag = 0 Then Display On Displayflag = 1 'Turn OFF LCD Elseif Displayflag = 1 Then Display Off Displayflag = 0 End If End If 'Use this button for retrieving your passwords ' Button = Pinb.7 ' If Button = 1 Then ' Cls ' Lcd "Button 6" ' End If Loop End Menu: 'Turn ON LCD Display On Displayflag = 1 'Clear LCD Cls 'Hide Cursor Cursor Off Noblink 'Top Line Lcd "popsci.com" Waitms 10 'Select Lower Line Lowerline Lcd "AVR-MT Pass Key" Wait 1 'Clear LCD Cls 'Place Cursor Line, Position Locate 1 , 1 Lcd "Create Passwords" Waitms 100 'Add a function for saving your passwords to EEPROM or PC via RS-232C Serial port 'Locate 1 , 1 'Lcd "And Save Them " 'Wait 1 'Clear LCD Cls 'Select Top Line Home Upper Lcd "Press Button:" Waitms 100 Lowerline Lcd "4 = Start" 'Add buttons for saving your passwords 'Waitms 100 'Lowerline 'Lcd "5 = Save" 'Waitms 100 'Lowerline 'Lcd "6 = Recall" Waitms 100 Lowerline Lcd "1 = Hide/Show" Waitms 100 Lowerline Lcd "Press 4 to Start" Return