Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Help to finalize my project "Home alarm system"

Status
Not open for further replies.

linuxnss

Newbie level 4
Joined
Dec 13, 2012
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,337
Hi friends,
kindly i don't know exactly where is the problem ,could you help me , i admit that am not good in electronic ,thus
in isis professional work fine with hex but when i implement it as a hardware not work

in the attached code + block diagram

and the power supply that i use +5 from phone charger or sometimes from USBport

this is code

unsigned short int kp,PWD = 0;
// Keypad module connections
char keypadPort at PORTD;
// End Keypad module connections

// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections

void system_disable()
{
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, "System Disable"); // Write message text on LCD
Lcd_Out(2, 1, "Enter Password");

}

void system_enable()
{
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, "System Enable"); // Write message text on LCD
Lcd_Out(2, 4, "Welcome");

}
void Wrong_PWD()
{
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, "System Disable"); // Write message text on LCD
Lcd_Out(2, 1, "Wrong password");

}

void LCD_alarm()
{
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, "System Enable"); // Write message text on LCD
Lcd_Out(2, 4, "Alarm");

}


char txt[6];
void main() {
int c,s;
int alarm;
c = 1; // Reset counter

TRISA=0x00;
TRISC=0b00000111; //3bits as a input for door and windows
Keypad_Init(); // Initialize Keypad
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
System_disable(); //system is disable at first working

do {
kp = 0; // Reset key code variable

// Wait for key to be pressed and released
do
{ // kp = Keypad_Key_Press(); // Store key code in kp variable
kp = Keypad_Key_Click(); // Store key code in kp variable

if (portc!=0)
{
alarm=1;
Lcd_Cmd(_LCD_CLEAR); // Clear LCD
LCD_alarm();
porta=0xff;
}
if ((s==2)&& (alarm==1) )
{
porta=0xff;
Sound_Init(&PORTE, 0);
Sound_Play(659, 250);
porta=0x00;
Sound_Init(&PORTE, 0);
Sound_Play(698, 250);

}


}
while (!kp);
// Prepare value for output, transform key to it's ASCII value
switch (kp) {
//case 10: kp = 42; break; // '*' // Uncomment this block for keypad4x3
//case 11: kp = 48; break; // '0'
//case 12: kp = 35; break; // '#'
//default: kp += 48;

case 1: kp = 1; break; // 1 // Uncomment this block for keypad4x4
case 2: kp = 2; break; // 2
case 3: kp = 3; break; // 3
case 4: kp = 65; break; // A
case 5: kp = 4; break; // 4
case 6: kp = 5; break; // 5
case 7: kp = 6; break; // 6
case 8: kp = 66; break; // B
case 9: kp = 7; break; // 7
case 10: kp = 8; break; // 8
case 11: kp = 9; break; // 9
case 12: kp = 67; break; // C
case 13: kp = 42; break; // *
case 14: kp = 0; break; // 0
case 15: kp = 35; break; // #
case 16: kp = 68; break; // D
}

if (kp != 0)
{ // Pressed key differs from previous

if (c==1)PWD=kp;
if (c==2)PWD=(PWD*10)+kp;
if(c<2) c=c+1;
else
{
if(PWD == 23 ) //system enable
{

porta=0b00100000; //send one's to button's
Lcd_Cmd(_LCD_CLEAR);
System_enable();
s=2;
}
if(PWD == 48) //system disable
{
Lcd_Cmd(_LCD_CLEAR); // Clear LCD
porta=0b00000000; //send 0 to button's
System_disable();
s=1;
alarm=0;
}
if((PWD != 48) && (PWD!=23)) //Wrong PWD entered system stay diable
{
Lcd_Cmd(_LCD_CLEAR); // Clear LCD
porta=0b00000000; //send 0 to button's
Wrong_PWD();
}
c=1; //reset key counter
} //else finished here

}






}
while (1);
}

Thanks, Project.JPG
 

Pull-down resistors should go on RD0, RD1, RD2, RD3. ..not RD4, RD5, RD6, RD7 as you have them.

See compiler help file for keypad.

I think that PORTC will need pull-down resistors too.
 
Last edited:
Many Thanks for your cooperation
i will try that , is there another hardware problem or just this one
 

is there another hardware problem or just this one
With pull-down resistors on RD0-3 and more pull-down resistors on RC0, RC1 and RC2, your project works for me on real hardware.

There are software improvements that could be made, but it works as it is.
 
i hope that Sir ,
on Monday i will go to university and try again ,to be honest i got bored why in simulation work in real no , unbelievable

Many Thanks for your cooperation
 

Hi hexreader,
currently keypad work fine , i have just one problem that LCD not work so i wonder
how can i check if this LCD damaged or not
"i applied +5V to PIN2 and PIN to GND" but seems no sign "is that mean that LCD damaged"
plz your advice to how to check the LCD
my LCD 16-pins
 

You need to also fit RV1 as in your schematic. Adjust RV1 until you see a single line of squares.
 
Okay Sir i will try that and send you the update
Many Thanks for your endless support,
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top