Electronic Safe: Code Snippet

void StoreKey(char *str)

{

ee_up = 0x00;

ee_low = ee_up + 5;

while (*str)

{

bit = *str++;

EEPROM_Write();

ee_up =ee_up+10; //test

ee_low = ee_up+5;

}

lastaddress = ee_up;

}



void GetKey(void)

{

ee_up = 0x00;

ee_low = ee_up +5;

while (ee_up != lastaddress)

{

EEPROM_Read();

UART_Put();

ee_up = ee_up +10;

ee_low = ee_up +5;

}

}

The code above is used to store a variable length PIN in EEPROM and retrieve it when needed. It starts at address 0x00 and increments by 10 for every successful digit. Once the PIN is stored it saves the last used address into a variable so the GetKey() function knows when to stop.

 

Electronic Safe: Big Picture

Electronic Safe:

The final project is an electronic safe that requires you enter the correct pin to open the safe. To create this safe a shoe box was used as an exterior housing, as well as a variety of components to perform the safe functions: a matrix style number pad, an LCD module, and a servo motor. The MCU to control the safe is an ATmega328p that was programed using a Windows 10 PC and Atmel Studio 7. The safe was unable to be completed, as the matrix style number pad was unable to be interpreted accurately; however, the rest of the safe functioned as predicted.