💾 Archived View for dfdn.info › dfdn › securitydemo › homesecurity.gmi captured on 2024-05-12 at 15:21:29. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-11-14)

-=-=-=-=-=-=-

/* Copyright � 14/11/2023 David Norris. A gift for for Africa's finest ladies.... To deploy and keep us safe.

And can also go into production for sale. Code may be used with my permission. */

/* Droit d'auteur � 14/11/2023 David Norris. Un cadeau pour les plus belles dames d'Afrique.... Pour nous d�ployer et assurer notre s�curit�.

Et peut �galement entrer en production pour la vente. Le code peut �tre utilis� avec ma permission. */

/* Ce projet est interessant tu peut faire un circuit d 'une

serrure*/

/dfdn/securitydemo/HomeSecurity.png

unsigned short kp,ks,kr,kt,ku,ky;

unsigned int i;

const char character[] = {0,17,14,4,14,17,0,0};

void CustomChar(char pos_row, char pos_char) {

char i;

Lcd_Cmd(64);

for (i = 0; i<=7; i++) Lcd_Chr_CP(character[i]);

Lcd_Cmd(_LCD_RETURN_HOME);

Lcd_Chr(pos_row, pos_char, 0);

}

// clavier module connection

char keypadPort at PORTC;

// clavier module connection

// LCD module connections

sbit LCD_RS at RB1_bit;

sbit LCD_EN at RB0_bit;

sbit LCD_D4 at RB4_bit;

sbit LCD_D5 at RB5_bit;

sbit LCD_D6 at RB6_bit;

sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB1_bit;

sbit LCD_EN_Direction at TRISB0_bit;

sbit LCD_D4_Direction at TRISB4_bit;

sbit LCD_D5_Direction at TRISB5_bit;

sbit LCD_D6_Direction at TRISB6_bit;

sbit LCD_D7_Direction at TRISB7_bit;

// End LCD module connections

void main()

{

TRISD.F1=0;

TRISA.F0=1;

do

{

Keypad_Init(); // Initialize Keypad

Lcd_Init(); // Initialize Lcd

Lcd_Cmd(_LCD_CLEAR); // Clear display

Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off

Lcd_Out(1, 1, "1");

Lcd_Out(1, 1, "code : "); // Write message text on Lcd

Sound_Init (& PORTD, 0);

kp = 0; // Reset key code variable

// Wait for key to be pressed and released

//kp = Keypad_Key_Press(); // Store key code in kp variable

do

kp = Keypad_Key_Click(); // Store key code in kp variable

while (!kp);

// Prepare value for output, transform key to it's ASCII value

switch (kp)

{

case 1: kp = 49; break; // 1

case 2: kp = 50; break; // 2

case 3: kp = 51; break; // 3

//case 4: kp = 65; break; // A

case 5: kp = 52; break; // 4

case 6: kp = 53; break; // 5

case 7: kp = 54; break; // 6

//case 8: kp = 66; break; // B

case 9: kp = 55; break; // 7

case 10: kp = 56; break; // 8

case 11: kp = 57; break; // 9

//case 12: kp = 67; break; // C

case 13: kp = 42; break; // *

case 14: kp = 48; break; // 0

case 15: kp = 35; break; // #

//case 16: kp = 68; break; // D

}

CustomChar(1,7);

ks = 0;

do

ks = Keypad_Key_Click(); // Store key code in kp variable

while (!ks);

// Prepare value for output, transform key to it's ASCII value

switch (ks)

{

case 1: ks = 49; break; // 1

case 2: ks = 50; break; // 2

case 3: ks = 51; break; // 3

//case 4: kp = 65; break; // A

case 5: ks = 52; break; // 4

case 6: ks = 53; break; // 5

case 7: ks = 54; break; // 6

//case 8: kp = 66; break; // B

case 9: ks = 55; break; // 7

case 10: ks = 56; break; // 8

case 11: ks = 57; break; // 9

//case 12: kp = 67; break; // C

case 13: ks = 42; break; // *

case 14: ks = 48; break; // 0

case 15: ks = 35; break; // #

//case 16: kp = 68; break; // D

}

CustomChar(1,8);

kr = 0; // Reset key code variable

// Wait for key to be pressed and released

//kp = Keypad_Key_Press(); // Store key code in kp variable

do

kr = Keypad_Key_Click(); // Store key code in kp variable

while (!kr);

// Prepare value for output, transform key to it's ASCII value

switch (kr)

{

case 1: kr = 49; break; // 1

case 2: kr = 50; break; // 2

case 3: kr = 51; break; // 3

//case 4: kp = 65; break; // A

case 5: kr = 52; break; // 4

case 6: kr = 53; break; // 5

case 7: kr = 54; break; // 6

//case 8: kp = 66; break; // B

case 9: kr = 55; break; // 7

case 10: kr = 56; break; // 8

case 11: kr = 57; break; // 9

//case 12: kp = 67; break; // C

case 13: kr = 42; break; // *

case 14: kr = 48; break; // 0

case 15: kr = 35; break; // #

//case 16: kp = 68; break; // D

}

CustomChar(1,9);

kt = 0;

do

kt = Keypad_Key_Click(); // Store key code in kp variable

while (!kt);

// Prepare value for output, transform key to it's ASCII value

switch (kt)

{

case 1: kt = 49; break; // 1

case 2: kt = 50; break; // 2

case 3: kt = 51; break; // 3

//case 4: kp = 65; break; // A

case 5: kt = 52; break; // 4

case 6: kt = 53; break; // 5

case 7: kt = 54; break; // 6

//case 8: kp = 66; break; // B

case 9: kt = 55; break; // 7

case 10: kt = 56; break; // 8

case 11: kt = 57; break; // 9

//case 12: kp = 67; break; // C

case 13: kt = 42; break; // *

case 14: kt = 48; break; // 0

case 15: kt = 35; break; // #

//case 16: kp = 68; break; // D

}

CustomChar(1,10);

ku = 0;

do

ku = Keypad_Key_Click(); // Store key code in kp variable

while (!ku);

// Prepare value for output, transform key to it's ASCII value

switch (ku)

{

case 1: ku = 49; break; // 1

case 2: ku = 50; break; // 2

case 3: ku = 51; break; // 3

//case 4: kp = 65; break; // A

case 5: ku = 52; break; // 4

case 6: ku = 53; break; // 5

case 7: ku = 54; break; // 6

//case 8: kp = 66; break; // B

case 9: ku = 55; break; // 7

case 10: ku = 56; break; // 8

case 11: ku = 57; break; // 9

//case 12: kp = 67; break; // C

case 13: ku = 42; break; // *

case 14: ku = 48; break; // 0

case 15: ku = 35; break; // #

//case 16: kp = 68; break; // D

}

CustomChar(1,11);

ky = 0;

do

ky = Keypad_Key_Click(); // Store key code in kp variable

while (!ky);

// Prepare value for output, transform key to it's ASCII value

switch (ky)

{

case 1: ky = 49; break; // 1

case 2: ky = 50; break; // 2

case 3: ky = 51; break; // 3

//case 4: kp = 65; break; // A

case 5: ky = 52; break; // 4

case 6: ky = 53; break; // 5

case 7: ky = 54; break; // 6

//case 8: kp = 66; break; // B

case 9: ky = 55; break; // 7

case 10: ky = 56; break; // 8

case 11: ky = 57; break; // 9

//case 12: kp = 67; break; // C

case 13: ky = 42; break; // *

case 14: ky = 48; break; // 0

case 15: ky = 35; break; // #

//case 16: kp = 68; break; // D

}

CustomChar(1,12);

// For demonstration this is set to 270695 - Gloria's birth date. This would need to be

// changed in practice as a very poor choice. (Anyone knowing her well could enter!!!

// I am a former security professional - believe me, I KNOW. This must be converted from

// ASCII values, hence 50,55,48,54,57,53 for 270695.

// Pour d�monstration, la valeur est 270695 - la date de naissance de Gloria. Cela devrait �tre

// a chang� en pratique comme un tr�s mauvais choix. (Tous ceux qui la connaissent bien peuvent participer !!!

// Je suis un ancien professionnel de la s�curit� � croyez-moi, je SAIS. Celui-ci doit �tre converti de

// Valeurs ASCII, donc 50,55,48,54,57,53 pour 270695.

Delay_ms(300);

if(kp==50 && ks==55 && kr==48 && kt==54 && ku==57 && ky==53)

{

Lcd_Out(2, 1, "code vrai ");

for(i=0;i<15;i++){

portD.F1=1; //servo 90�degr�e

Delay_us(2000);

portD.F1=0;}

}

else

{

Lcd_Out(2, 1, "code incorrect ");

Sound_Play (2000, 400); //g�n�rer du son

Sound_Play (1000, 260); //g�n�rer du son

Sound_Play (2000, 400); //g�n�rer du son

for(i=0;i<15;i++){

portD.F1=1; //servo 90�degr�e

Delay_us(1500);

portD.F1=0;}

}

Delay_ms(3000);

} while (1);

}