الاستاذ الكريم
ايه الاخبار
هل يوجد صعوبة فى تنفيذ الطلبين
|
السلام عليكم ورحمه الله وبركاته ..
تم بحمد الله اضافة رقم سري للمشروع .. الرقم السري هو (1234) ويمكنك تغيرة كما تشاء .. من خلال الكود وايضاااا يمكنك تزويدة كما تشاء
اليك الكود ...
كود:
// <<*** keypadPort _ ON AND OFF LED ****>> //
// ***** ENG / ABDALLA HYGAZY ****** //
// ***** DATA / 2017 / 2 / 4 ***** //
// Lcd pinout settings
#define SHOW inttostr(pot,potstring); Lcd_Out(2, 7,potstring );
sbit LCD_RS at RB5_bit;
sbit LCD_EN at RB4_bit;
sbit LCD_D7 at RB0_bit;
sbit LCD_D6 at RB1_bit;
sbit LCD_D5 at RB2_bit;
sbit LCD_D4 at RB3_bit;
// Pin direction
sbit LCD_RS_Direction at TRISB5_bit;
sbit LCD_EN_Direction at TRISB4_bit;
sbit LCD_D7_Direction at TRISB0_bit;
sbit LCD_D6_Direction at TRISB1_bit;
sbit LCD_D5_Direction at TRISB2_bit;
sbit LCD_D4_Direction at TRISB3_bit;
//***********************************//
char led,goo_out=0,goo_en=0;
int pot=0,X=0,A=0,A1=0;
char potstring[16];
//************************************//
char keypadPort at PORTD;
int i;
char password[5];
//*********************************//
char get_password()
{
Loop:
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1, 1, "Enter Password :");
for(i=0;i<4;i++)
{
while (password[i] == 0)
{
password[i] = Keypad_Key_Click();
}
if(password[i]==1) password[i] = '1';
if(password[i]==2) password[i] = '2';
if(password[i]==3) password[i] = '3';
// if(password[i]==4) password[i] = 'A';
if(password[i]==5) password[i] = '4';
if(password[i]==6) password[i] = '5';
if(password[i]==7) password[i] = '6';
// if(password[i]==8) password[i] = 'B';
if(password[i]==9) password[i] = '7';
if(password[i]==10) password[i] = '8';
if(password[i]==11) password[i] = '9';
// if(password[i]==12) password[i] = 'C';
if(password[i]==13) password[i] = '*';
if(password[i]==14) password[i] = '0';
// if(password[i]==15) password[i] = '#';
// if(password[i]==16) password[i] = 'D';
Lcd_Chr(2, i+1, '*');
}
if(strcmp(password,"1234") == 0) {return 1;}
else {
password[0] = 0;
password[1] = 0;
password[2] = 0;
password[3] = 0;
Lcd_Out(2, 3, "Error");
delay_ms(2000);
goto Loop;
}
}
void main() {
Keypad_Init();
TRISB =0; PORTB=0;
TRISC =0; PORTC=0;
TRISA =0; PORTA=0;
TRISE =0; PORTE=0;
adcon1=0x06;
Lcd_Init();
//************-----------***************//
Lcd_Cmd(_LCD_CLEAR);
Lcd_Cmd(_LCD_CURSOR_OFF);
Lcd_Out(1, 3, "Hello!");
delay_ms(1500);
Lcd_Cmd(_LCD_CLEAR);
//************-----------****************//
get_password();
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,2 , "WELCOME");
// portc.b0 = ~ portc.b0;
delay_ms(3000);
Lcd_Cmd(_LCD_CLEAR);
//****************************************************//
while(goo_out==0){
goo_en=0; pot=0; led=0;
Lcd_Out(1, 1, "function key led");
Lcd_Out(2, 1, "LED ON ( )");
while(!led){led = Keypad_Key_Click();}
switch (led) {
case 1: led = porta=1; portc=0; porte=0; goo_out=1; pot=1; Lcd_Out(3, 2, ">> MOHAMED <<"); SHOW break; // 1
case 2: led = porta=2; portc=0; porte=0; goo_out=1; pot=2; Lcd_Out(3, 2, ">> AHMED <<"); SHOW break; // 2
case 3: led = porta=4; portc=0; porte=0; goo_out=1; pot=3; Lcd_Out(3, 2, ">> ALI <<"); SHOW break; // 3
case 4: led = porta=8; portc=0; porte=0; goo_out=1; pot=4; Lcd_Out(3, 2, ">> ABDALLA <<"); SHOW break; // A
case 5: led = porta=32; portc=0; porte=0; goo_out=1; pot=5; Lcd_Out(3, 2, ">> MOHMOD <<"); SHOW break; // 4
case 6: led = porte=1; portc=0; porta=0; goo_out=1; pot=6; SHOW break; // 5
case 7: led = porte=2; portc=0; porta=0; goo_out=1; pot=7; SHOW break; // 6
case 8: led = porte=4; portc=0; porta=0; goo_out=1; pot=8; SHOW break; // B
case 9: led = portc=1; porta=0; porte=0; goo_out=1; pot=9; SHOW break; // 7
case 10: led = portc=2; porta=0; porte=0; goo_out=1; pot=10; SHOW break; // 8
case 11: led = portc=4; porta=0; porte=0; goo_out=1; pot=11; SHOW break; // 9
case 12: led = portc=8; porta=0; porte=0; goo_out=1; pot=12; SHOW break; // C
case 13: led = portc=16; porta=0; porte=0; goo_out=1; pot=13; SHOW break; // *
//case 14: led = portc=32; porta=0; porte=0; goo_out=1; pot=14; SHOW break; // 0
case 15: led = portc=64; porta=0; porte=0; goo_out=1; pot=15; SHOW break; // #
case 16: led = portc=128; porta=0; porte=0; goo_out=1; pot=16; SHOW break; // D
}
//***************************************************************//
while(goo_en==0){ led=0;
while(!led){led = Keypad_Key_Click();}
switch (led) {
case 14: led = portc=0; portb=0; porta=0; porte=0;
goo_en=1; goo_out=0; Lcd_Cmd(_LCD_CLEAR); break; // 0
}
}
//*****************************************************************//
}
}
صورة للمشروع ....
المشروع كامل للتحميل ...
https://drive.google.com/file/d/0Bxg...ew?usp=sharing
ملحوظه هذا الميكرو لا يتحمل المذيد من الأوامر لأن الذاكرة تكاد تنفذ .. وهناك صفحات لعرض البيانات علي الشاشة وهي محدودة جداااا ..
يمكنك اختيار ميكرو أخر لتنفيذ المشروع علية ..
ملحوظة يمكنك تغير الرقم السري المكون من اربع ارقام من خلال هذا السطر في الكود فقط غير الأربع ارقام كما تشاء ..
كود:
if(strcmp(password,"1234") == 0) {return 1;}
علي فكرة لم تذكر ما هي فائدة الراليه أو فيما يستخدم .. ؟؟؟؟
تحياتي لك وبالتوفيق ....