 |
:: عضو ذهبي ::
تاريخ التسجيل: Apr 2011
الدولة: مصر .. محافظة دمياط
المشاركات: 1,682
|
|
نشاط [ عبدالله حجازى ]
قوة السمعة:
|
|
12-09-2019, 03:21 AM
المشاركة 15
|
|
السلام عليكم ورحمه الله
تفضل أخي هذا كود البرنامج
كود:
// Design Program Engineer ABDALLA HYGAZY //
// Lighting consecutive //
// Date / 2016 / 2 /15 //
unsigned timer;
int x =0;
int m =0;
//---------------------------//
#define flash for(m=0;m<5;m++)
#define LED1_ON GP5_bit = 1;
#define LED2_ON GP4_bit = 1;
#define LED3_ON GP2_bit = 1;
#define LED4_ON GP1_bit = 1;
//**************************//
#define LED1_OF GP5_bit = 0;
#define LED2_OF GP4_bit = 0;
#define LED3_OF GP2_bit = 0;
#define LED4_OF GP1_bit = 0;
//**************************//
#define time timer_variabe();
//**************************//
#define BUTTON if(GP3_bit==0){goto loop;};
//----------------------------------------//
void init_ports(void) {
TRISIO = 9; // set as output
ANSEL = 1;
CMCON = 7;
}
void timer_variabe()
{
for(x=0;x< timer; x++)
{
delay_ms(120);
}
}
void ADC_Read_bit0()
{
timer = ADC_Read(0); // Read analog value from channel 2
timer= (timer*5)/1023;
}
void main() {
init_ports();
ADC_Init();
GPIO = 0;
while(1) {
//********* program ( 1 ) ********//
flash
{
BUTTON
ADC_Read_bit0();
GPIO = 255; time
GPIO = 0; time
}
//----------------------------------//
//********* program ( 2 ) *********//
flash
{
BUTTON
ADC_Read_bit0();
LED1_ON time LED2_ON time
LED3_ON time LED4_ON time
GPIO = 0; time
}
//-----------------------------------//
//********* program ( 3 ) **********//
flash
{
BUTTON
ADC_Read_bit0();
GPIO = 32; time GPIO = 16; time
GPIO = 4; time GPIO = 2; time
GPIO = 4; time GPIO = 16; time
}
//---------------------------------//
//********* program ( 4 ) **********//
flash
{
BUTTON
ADC_Read_bit0();
GPIO = 32; time GPIO = 16; time
GPIO = 4; time GPIO = 2; time
GPIO = 4; time GPIO = 16; time
}
//-----------------------------------//
//******** program ( 5 ) **********//
flash
{
BUTTON
ADC_Read_bit0();
GPIO = 34; time
GPIO = 20; time
GPIO = 34; time
GPIO = 20; time
}
//----------------------------------//
//******* program ( 6 ) **********//
flash
{
BUTTON
ADC_Read_bit0();
LED1_ON time LED2_ON time
LED3_ON time LED4_ON time
GPIO = 0; time
LED4_ON time LED3_ON time
LED2_ON time LED1_ON time
GPIO = 0; time
}
//----------------------------------//
//******** program ( 7 ) **********//
flash
{
BUTTON
ADC_Read_bit0();
LED1_ON LED3_ON time
LED1_OF LED3_OF time
LED2_ON LED4_ON time
LED2_OF LED4_OF time
}
//---------------------------------//
//******* program ( 8 ) **********//
flash
{
BUTTON
ADC_Read_bit0();
GPIO = 255; time
GPIO = 223; time
GPIO = 239; time
GPIO = 251; time
GPIO = 253; time
ADC_Read_bit0();
GPIO = 255; time
BUTTON
GPIO = 253; time
GPIO = 251; time
GPIO = 239; time
GPIO = 223; time
GPIO = 255; time
}
//--------------------------------//
//*******program ( 9 ) **********//
flash
{
BUTTON
ADC_Read_bit0();
GPIO = 32; time GPIO = 16; time
GPIO = 4; time GPIO = 2; time
GPIO = 255; time GPIO = 0 ; time
GPIO = 255; time GPIO = 0 ; time
GPIO = 2; time GPIO = 4; time
GPIO = 16; time GPIO = 32; time
GPIO = 255; time GPIO = 0 ; time
GPIO = 255; time GPIO = 0 ; time
}
if(GP3_bit==1){goto loop;};
}
//---------------------------------//
loop:
GPIO = 255; delay_ms(5000);
while(1) {
//******** program ( 10 ) ********//
flash
{
ADC_Read_bit0();
GPIO = 32; time GPIO = 16; time
GPIO = 4; time GPIO = 2; time
GPIO = 32; time GPIO = 16; time
GPIO = 4; time GPIO = 2; time
GPIO = 2; time GPIO = 4; time
GPIO = 16; time GPIO = 32; time
GPIO = 2; time GPIO = 4; time
GPIO = 16; time GPIO = 32; time
}
//-----------------------------------//
//******* program ( 11 ) *********//
flash
{
ADC_Read_bit0();
GPIO = 32; time GPIO = 16; time
GPIO = 4; time GPIO = 2; time
GPIO = 4; time GPIO = 16; time
}
//---------------------------------------------------//
//*************** program ( 12 ) ********************/
flash
{
ADC_Read_bit0();
GPIO = 255; delay_ms(500); time GPIO = 0; time time
}
//---------------------------------------------------//
//*****************program ( 12 ) *******************//
flash
{
ADC_Read_bit0();
GPIO = 255; time GPIO = 0; time
}
//***************************************************//
}
}

المشروع كامل للتحميل
https://drive.google.com/open?id=1c7...lk6xg408rj2_iU
بالتوفيق أخي
|