قسم الميكروكنترولر والروبوت ودوائر الاتصال بالحاسب الالي قسم المتحكمات الـ microcontroller و المعالجات microprocessor و التحكم الرقمي بالكمبيوتر CNC والانظمة الآلية والروبوت Robots

أدوات الموضوع

الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,894
نشاط [ F.Abdelaziz ]
قوة السمعة:328
قديم 09-03-2016, 10:13 PM المشاركة 1   
افتراضي مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد ياستخدام الميكروكونتر Twitter FaceBook Google+



مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد الثمن ياستخدام الميكروكونترولر PIC16F628A
الدائرة الكهربية :




الوصف :
المشروع مزود بمفتاح ON-OFF ومقاومة متغيرة (يمن استخدام مفتاح ON-OFF وفوليوم المعروف)
فى حالة فصل المفتاح :
يتم عرض نموذج ثابت لا يتغير .
فى حالة توصيل المفتاح :
يتم عرض إضاءة متحركة بعدد من النماذج الشائعة مع التحكم فى سرعة العرض .
التحكم فى السرعة :
يتم عن طريق استخدام ساعة RCخارجية مع مقاومة متغيرة للتحكم فى تردد الساعة وبالتالى سرعة تنفيذ التعليمات .
نماذج الإضاءة :
يوجد 8 مخارج متصلة بالمنفذ PORTB ولذلك تكون نماذج الإضاءة فى شكل نماذج لبايتات ذات8 بت وكل بت تقابل ليد ، تعيين البت بواحد يعنى إضاءة الليد ، فى حين تعيين البت بصفر يعنى إطفاء الليد . وحتى نتمكن من تنفيذ أكبر عدد من النماذج ينبغى حفظها فى ذاكرة البرنامج لأنها الأكبر .
البرنامج :


كود:
// LED Light Sequencer
// PIC16F628 RC CLOCK 
// Change for different length patterns.
 #define PATTERNLENGTH 221
// Declare functions
 unsigned short int getPattern(unsigned short int index);
////////////////////////////////////
unsigned short int count; // Declare loop counter
/////////////////////////////////////
 // Main program loop
 void main()
 {
 CMCON = 0x07; // To turn off comparators
 TRISB=0; // Set all Port B to outputs
 TRISA.F0=1;
 PORTB=0;
 while(1) // Loop forever
 {
	if(Button(&PORTA,0,20,1)){
		PORTB=0b11111111;
		delay_ms(250);
		PORTB=0b00000000;
		delay_ms(250);
	}
 else{
	
	// Loop from 0 to PATTERNLENGTH-1
	for(count = 0; count < PATTERNLENGTH; count++){
	// Get the next pattern and output to LEDs
		PORTB = getPattern(count);
 // Pause for the specified number of ms (up to 65535)
		delay_ms(250);
		}
	}
  }
 }
//////////////////////////////////////////////
// getPattern function: returns the index-th output pattern
 // in the desired sequence
 unsigned short int getPattern(unsigned short int index)
 {
 const unsigned short int patternArray[PATTERNLENGTH] = {
 ///////1A-moving from right to left ////////////////////
0b00000001,// For each pattern in the sequence,
0b00000010,// 1 = light on, 0 = off
0b00000100,// Any combination of lights can be on or off
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
///////1B-moving from right to left ///////
0b00000001,
0b00000010,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
///////////2A-moving from left to right ////////
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
///////////2B-moving from left to right ////////
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
////////////3A-moving from left to right then moving from left to right  ////////
0b00000001,
0b00000010,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
0b00000000,
//3B-moving from left to right then moving from left to right//
0b00000001,
0b00000010,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000000,
////////4-moving from center to edges//////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b00000000,
/////////5-moving from edges to center ////////
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
//////////6A///////////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
/////////////6B/////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
////////7/////////////////////
0b00000000,
0b10000000,
0b11000000,
0b11100000,
0b11110000,
0b01111000,
0b00111100,
0b00011110,
0b00001111,
0b00000111,
0b00000011,
0b00000001,
0b00000000,
//////////8///////////
0b00000000,
0b00000001,
0b00000011,
0b00000111,
0b00001111,
0b00011110,
0b00111100,
0b01111000,
0b11110000,
0b11100000,
0b11000000,
0b10000000,
0b00000000,
///////////9////////////////
0b00000001,
0b00000100,
0b00000010,
0b00001000,
0b00000100,
0b00010000,
0b00001000,
0b00100000,
0b00010000,
0b01000000,
0b00100000,
0b10000000,
0b01000000,
0b00000000,
///////////10///////////////
0b00000000,
0b01000000,
0b10000000,
0b00100000,
0b01000000,
0b00010000,
0b00100000,
0b00001000,
0b00010000,
0b00000100,
0b00001000,
0b00000010,
0b00000100,
0b00000001,
0b00000000,
///////11A////////////////////
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////11B////////////
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
/////////////12///////////////////
0b00000000,
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00000000,
/////////////13//////////////
0b00000000,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////14A////////////
0b00000000,
0b00001111,
0b11110000,
0b00001111,
0b11110000,
0b00000000,
///////////14B////////////////////////
0b00001111,
0b11110000,
//////////////15A////////////////////
0b00000000,
0b01010101,
0b10101010,
0b01010101,
0b10101010,
0b00000000,
////////////15B////////////////////
0b01010101,
0b10101010,
//////////////16////////////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 ///////////////
 0b01111111, 
 0b00111111, 
 0b00011111, 
 0b00001111,
 0b00000111,
 0b00000011,
 0b00000001,
 0b00000000,
 ///////////17//////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 /////////////////////
 0b11111110, 
 0b11111100, 
 0b11111000, 
 0b11110000,
 0b11100000,
 0b11000000,
 0b10000000,
 0b00000000,
 ///////////18///////////
 0b11111111, // For each pattern in the sequence,
 0b00000000, // 1 = light on, 0 = off
 0b11111111, // Any combination of lights can be on or off
 0b00000000,
 0b11111111, // NB: Length of this list must be
 0b00000000, // the same as PATTERNLENGTH
 //////////////////
};
 return patternArray[index];
 }

احصائية الشكر والاعجاب - 2 شكراً, 0 عدم اعجاب, 2 اعجاب
شكراً najee22, عبدالله حجازى ( شكر العضو على هذه المشاركة )
اعجاب najee22, عبدالله حجازى ( أعجبته المشاركة )
اعلانات

حمد سيد
:: مهندس ::
تاريخ التسجيل: Jan 2015
المشاركات: 44
نشاط [ حمد سيد ]
قوة السمعة:0
قديم 10-03-2016, 02:45 AM المشاركة 2   
افتراضي


مشروع أضواء متلاحقة 8 مخارج متعدد النماذج والسرعات ، بسيط وذهيد الثمن ياستخدام الميكروكونترولر PIC16F628A
الدائرة الكهربية :




الوصف :
المشروع مزود بمفتاح ON-OFF ومقاومة متغيرة (يمن استخدام مفتاح ON-OFF وفوليوم المعروف)
فى حالة فصل المفتاح :
يتم عرض نموذج ثابت لا يتغير .
فى حالة توصيل المفتاح :
يتم عرض إضاءة متحركة بعدد من النماذج الشائعة مع التحكم فى سرعة العرض .
التحكم فى السرعة :
يتم عن طريق استخدام ساعة RCخارجية مع مقاومة متغيرة للتحكم فى تردد الساعة وبالتالى سرعة تنفيذ التعليمات .
نماذج الإضاءة :
يوجد 8 مخارج متصلة بالمنفذ PORTB ولذلك تكون نماذج الإضاءة فى شكل نماذج لبايتات ذات8 بت وكل بت تقابل ليد ، تعيين البت بواحد يعنى إضاءة الليد ، فى حين تعيين البت بصفر يعنى إطفاء الليد . وحتى نتمكن من تنفيذ أكبر عدد من النماذج ينبغى حفظها فى ذاكرة البرنامج لأنها الأكبر .
البرنامج :


كود:
// LED Light Sequencer
// PIC16F628 RC CLOCK 
// Change for different length patterns.
 #define PATTERNLENGTH 221
// Declare functions
 unsigned short int getPattern(unsigned short int index);
////////////////////////////////////
unsigned short int count; // Declare loop counter
/////////////////////////////////////
 // Main program loop
 void main()
 {
 CMCON = 0x07; // To turn off comparators
 TRISB=0; // Set all Port B to outputs
 TRISA.F0=1;
 PORTB=0;
 while(1) // Loop forever
 {
	if(Button(&PORTA,0,20,1)){
		PORTB=0b11111111;
		delay_ms(250);
		PORTB=0b00000000;
		delay_ms(250);
	}
 else{
	
	// Loop from 0 to PATTERNLENGTH-1
	for(count = 0; count < PATTERNLENGTH; count++){
	// Get the next pattern and output to LEDs
		PORTB = getPattern(count);
 // Pause for the specified number of ms (up to 65535)
		delay_ms(250);
		}
	}
  }
 }
//////////////////////////////////////////////
// getPattern function: returns the index-th output pattern
 // in the desired sequence
 unsigned short int getPattern(unsigned short int index)
 {
 const unsigned short int patternArray[PATTERNLENGTH] = {
 ///////1A-moving from right to left ////////////////////
0b00000001,// For each pattern in the sequence,
0b00000010,// 1 = light on, 0 = off
0b00000100,// Any combination of lights can be on or off
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
///////1B-moving from right to left ///////
0b00000001,
0b00000010,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
///////////2A-moving from left to right ////////
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
///////////2B-moving from left to right ////////
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
////////////3A-moving from left to right then moving from left to right  ////////
0b00000001,
0b00000010,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000001,
0b00000000,
//3B-moving from left to right then moving from left to right//
0b00000001,
0b00000010,
0b00000100,
0b00001000,
0b00010000,
0b00100000,
0b01000000,
0b10000000,
0b01000000,
0b00100000,
0b00010000,
0b00001000,
0b00000100,
0b00000010,
0b00000000,
////////4-moving from center to edges//////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b00000000,
/////////5-moving from edges to center ////////
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
//////////6A///////////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
/////////////6B/////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
////////7/////////////////////
0b00000000,
0b10000000,
0b11000000,
0b11100000,
0b11110000,
0b01111000,
0b00111100,
0b00011110,
0b00001111,
0b00000111,
0b00000011,
0b00000001,
0b00000000,
//////////8///////////
0b00000000,
0b00000001,
0b00000011,
0b00000111,
0b00001111,
0b00011110,
0b00111100,
0b01111000,
0b11110000,
0b11100000,
0b11000000,
0b10000000,
0b00000000,
///////////9////////////////
0b00000001,
0b00000100,
0b00000010,
0b00001000,
0b00000100,
0b00010000,
0b00001000,
0b00100000,
0b00010000,
0b01000000,
0b00100000,
0b10000000,
0b01000000,
0b00000000,
///////////10///////////////
0b00000000,
0b01000000,
0b10000000,
0b00100000,
0b01000000,
0b00010000,
0b00100000,
0b00001000,
0b00010000,
0b00000100,
0b00001000,
0b00000010,
0b00000100,
0b00000001,
0b00000000,
///////11A////////////////////
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////11B////////////
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
/////////////12///////////////////
0b00000000,
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00000000,
/////////////13//////////////
0b00000000,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////14A////////////
0b00000000,
0b00001111,
0b11110000,
0b00001111,
0b11110000,
0b00000000,
///////////14B////////////////////////
0b00001111,
0b11110000,
//////////////15A////////////////////
0b00000000,
0b01010101,
0b10101010,
0b01010101,
0b10101010,
0b00000000,
////////////15B////////////////////
0b01010101,
0b10101010,
//////////////16////////////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 ///////////////
 0b01111111, 
 0b00111111, 
 0b00011111, 
 0b00001111,
 0b00000111,
 0b00000011,
 0b00000001,
 0b00000000,
 ///////////17//////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 /////////////////////
 0b11111110, 
 0b11111100, 
 0b11111000, 
 0b11110000,
 0b11100000,
 0b11000000,
 0b10000000,
 0b00000000,
 ///////////18///////////
 0b11111111, // For each pattern in the sequence,
 0b00000000, // 1 = light on, 0 = off
 0b11111111, // Any combination of lights can be on or off
 0b00000000,
 0b11111111, // NB: Length of this list must be
 0b00000000, // the same as PATTERNLENGTH
 //////////////////
};
 return patternArray[index];
 }
جميل اوي نظام الكتابه كده وعلي فكره انا اول مره اعرف شكل الاشكال الدات من الكتابه مينفعش اكتب بلرموز ده عل البك12f675 ولوينفع تكتبلى نفس الاشكال ده وانا ممكن اعدل عليها

اعلانات اضافية ( قم بتسجيل الدخول لاخفائها )
  

الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,894
نشاط [ F.Abdelaziz ]
قوة السمعة:328
قديم 10-03-2016, 09:56 AM المشاركة 3   
افتراضي


تعديل المشروع للاستخدام مع الميكروكونترولر PIC12F675 :



البرنامج :
مع تعديل جزء منه وترك باقى التعديل ليتم بمعرفة المستخدم :



كود:
// LED Light Sequencer
// PIC16F628 RC CLOCK 
// Change for different length patterns.
 #define PATTERNLENGTH 221
// Declare functions
 unsigned short int getPattern(unsigned short int index);
////////////////////////////////////
unsigned short int count; // Declare loop counter
/////////////////////////////////////
 // Main program loop
 void main()
 {
 CMCON = 0x07; // To turn off comparators
 ANSEL=0;//ALL PINS DIGITAL I/O 
 TRISIO=0b00001000; // only GP3 as input 
  while(1) // Loop forever
 {
	if(Button(&GPIO,3,20,0)){
		GPIO=0b110111;// For PIC12F675 0bxx000000
		delay_ms(250);
		GPIO=0b000000;
		delay_ms(250);
	}
 else{
	
	// Loop from 0 to PATTERNLENGTH-1
	for(count = 0; count < PATTERNLENGTH; count++){
	// Get the next pattern and output to LEDs
		GPIO = getPattern(count);
 // Pause for the specified number of ms (up to 65535)
		delay_ms(250);
		}
	}
  }
 }
//////////////////////////////////////////////
// getPattern function: returns the index-th output pattern
 // in the desired sequence
 unsigned short int getPattern(unsigned short int index)
 {
 const unsigned short int patternArray[PATTERNLENGTH] = {
 ///////1A-moving from right to left ////////////////////
0b000001,// For each pattern in the sequence,
0b000010,// 1 = light on, 0 = off
0b000100,// Any combination of lights can be on or off
0b010000,
0b100000,
///////1B-moving from right to left ///////
0b000001,
0b000010,
0b000100,
0b010000,
0b100000,
///////////2A-moving from left to right ////////
0b100000,
0b10000,
0b000100,
0b000010,
0b000001,
///////////2B-moving from left to right ////////
0b100000,
0b010000,
0b000100,
0b000010,
0b000001,
////////////3A-moving from left to right then moving from left to right  ////////
0b000001,
0b000010,
0b000100,
0b010000,
0b100000,
0b010000,
0b000100,
0b000010,
0b000001,
//3B-moving from left to right then moving from left to right//
0b000010,
0b000100,
0b010000,
0b100000,
0b100000,
0b010000,
0b000100,
0b000010,
/*
////////4-moving from center to edges//////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b00000000,
/////////5-moving from edges to center ////////
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
//////////6A///////////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
/////////////6B/////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
////////7/////////////////////
0b00000000,
0b10000000,
0b11000000,
0b11100000,
0b11110000,
0b01111000,
0b00111100,
0b00011110,
0b00001111,
0b00000111,
0b00000011,
0b00000001,
0b00000000,
//////////8///////////
0b00000000,
0b00000001,
0b00000011,
0b00000111,
0b00001111,
0b00011110,
0b00111100,
0b01111000,
0b11110000,
0b11100000,
0b11000000,
0b10000000,
0b00000000,
///////////9////////////////
0b00000001,
0b00000100,
0b00000010,
0b00001000,
0b00000100,
0b00010000,
0b00001000,
0b00100000,
0b00010000,
0b01000000,
0b00100000,
0b10000000,
0b01000000,
0b00000000,
///////////10///////////////
0b00000000,
0b01000000,
0b10000000,
0b00100000,
0b01000000,
0b00010000,
0b00100000,
0b00001000,
0b00010000,
0b00000100,
0b00001000,
0b00000010,
0b00000100,
0b00000001,
0b00000000,
///////11A////////////////////
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////11B////////////
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
/////////////12///////////////////
0b00000000,
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00000000,
/////////////13//////////////
0b00000000,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////14A////////////
0b00000000,
0b00001111,
0b11110000,
0b00001111,
0b11110000,
0b00000000,
///////////14B////////////////////////
0b00001111,
0b11110000,
//////////////15A////////////////////
0b00000000,
0b01010101,
0b10101010,
0b01010101,
0b10101010,
0b00000000,
////////////15B////////////////////
0b01010101,
0b10101010,
//////////////16////////////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 ///////////////
 0b01111111, 
 0b00111111, 
 0b00011111, 
 0b00001111,
 0b00000111,
 0b00000011,
 0b00000001,
 0b00000000,
 ///////////17//////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 /////////////////////
 0b11111110, 
 0b11111100, 
 0b11111000, 
 0b11110000,
 0b11100000,
 0b11000000,
 0b10000000,
 0b00000000,
 ///////////18///////////
 0b11111111, // For each pattern in the sequence,
 0b00000000, // 1 = light on, 0 = off
 0b11111111, // Any combination of lights can be on or off
 0b00000000,
 0b11111111, // NB: Length of this list must be
 0b00000000, // the same as PATTERNLENGTH
 //////////////////
 */
};
 return patternArray[index];
 }

احصائية الشكر والاعجاب - 0 شكراً, 0 عدم اعجاب, 1 اعجاب
اعجاب عبدالله حجازى ( أعجبته المشاركة )

حمد سيد
:: مهندس ::
تاريخ التسجيل: Jan 2015
المشاركات: 44
نشاط [ حمد سيد ]
قوة السمعة:0
قديم 10-03-2016, 04:57 PM المشاركة 4   
افتراضي


تعديل المشروع للاستخدام مع الميكروكونترولر PIC12F675 :



البرنامج :
مع تعديل جزء منه وترك باقى التعديل ليتم بمعرفة المستخدم :



كود:
// LED Light Sequencer
// PIC16F628 RC CLOCK 
// Change for different length patterns.
 #define PATTERNLENGTH 221
// Declare functions
 unsigned short int getPattern(unsigned short int index);
////////////////////////////////////
unsigned short int count; // Declare loop counter
/////////////////////////////////////
 // Main program loop
 void main()
 {
 CMCON = 0x07; // To turn off comparators
 ANSEL=0;//ALL PINS DIGITAL I/O 
 TRISIO=0b00001000; // only GP3 as input 
  while(1) // Loop forever
 {
	if(Button(&GPIO,3,20,0)){
		GPIO=0b110111;// For PIC12F675 0bxx000000
		delay_ms(250);
		GPIO=0b000000;
		delay_ms(250);
	}
 else{
	
	// Loop from 0 to PATTERNLENGTH-1
	for(count = 0; count < PATTERNLENGTH; count++){
	// Get the next pattern and output to LEDs
		GPIO = getPattern(count);
 // Pause for the specified number of ms (up to 65535)
		delay_ms(250);
		}
	}
  }
 }
//////////////////////////////////////////////
// getPattern function: returns the index-th output pattern
 // in the desired sequence
 unsigned short int getPattern(unsigned short int index)
 {
 const unsigned short int patternArray[PATTERNLENGTH] = {
 ///////1A-moving from right to left ////////////////////
0b000001,// For each pattern in the sequence,
0b000010,// 1 = light on, 0 = off
0b000100,// Any combination of lights can be on or off
0b010000,
0b100000,
///////1B-moving from right to left ///////
0b000001,
0b000010,
0b000100,
0b010000,
0b100000,
///////////2A-moving from left to right ////////
0b100000,
0b10000,
0b000100,
0b000010,
0b000001,
///////////2B-moving from left to right ////////
0b100000,
0b010000,
0b000100,
0b000010,
0b000001,
////////////3A-moving from left to right then moving from left to right  ////////
0b000001,
0b000010,
0b000100,
0b010000,
0b100000,
0b010000,
0b000100,
0b000010,
0b000001,
//3B-moving from left to right then moving from left to right//
0b000010,
0b000100,
0b010000,
0b100000,
0b100000,
0b010000,
0b000100,
0b000010,
/*
////////4-moving from center to edges//////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b00000000,
/////////5-moving from edges to center ////////
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
//////////6A///////////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
0b00011000,
0b00000000,
/////////////6B/////////////////
0b00011000,
0b00100100,
0b01000010,
0b10000001,
0b01000010,
0b00100100,
////////7/////////////////////
0b00000000,
0b10000000,
0b11000000,
0b11100000,
0b11110000,
0b01111000,
0b00111100,
0b00011110,
0b00001111,
0b00000111,
0b00000011,
0b00000001,
0b00000000,
//////////8///////////
0b00000000,
0b00000001,
0b00000011,
0b00000111,
0b00001111,
0b00011110,
0b00111100,
0b01111000,
0b11110000,
0b11100000,
0b11000000,
0b10000000,
0b00000000,
///////////9////////////////
0b00000001,
0b00000100,
0b00000010,
0b00001000,
0b00000100,
0b00010000,
0b00001000,
0b00100000,
0b00010000,
0b01000000,
0b00100000,
0b10000000,
0b01000000,
0b00000000,
///////////10///////////////
0b00000000,
0b01000000,
0b10000000,
0b00100000,
0b01000000,
0b00010000,
0b00100000,
0b00001000,
0b00010000,
0b00000100,
0b00001000,
0b00000010,
0b00000100,
0b00000001,
0b00000000,
///////11A////////////////////
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////11B////////////
0b00110000,
0b00001100,
0b00000011,
0b00001100,
0b00110000,
/////////////12///////////////////
0b00000000,
0b11000000,
0b00110000,
0b00001100,
0b00000011,
0b00000000,
/////////////13//////////////
0b00000000,
0b00000011,
0b00001100,
0b00110000,
0b11000000,
0b00000000,
//////////////14A////////////
0b00000000,
0b00001111,
0b11110000,
0b00001111,
0b11110000,
0b00000000,
///////////14B////////////////////////
0b00001111,
0b11110000,
//////////////15A////////////////////
0b00000000,
0b01010101,
0b10101010,
0b01010101,
0b10101010,
0b00000000,
////////////15B////////////////////
0b01010101,
0b10101010,
//////////////16////////////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 ///////////////
 0b01111111, 
 0b00111111, 
 0b00011111, 
 0b00001111,
 0b00000111,
 0b00000011,
 0b00000001,
 0b00000000,
 ///////////17//////////
 0b00000001, // For each pattern in the sequence,
 0b00000011, // 1 = light on, 0 = off
 0b00000111, // Any combination of lights can be on or off
 0b00001111,
 0b00011111,
 0b00111111,
 0b01111111,
 0b11111111,
 /////////////////////
 0b11111110, 
 0b11111100, 
 0b11111000, 
 0b11110000,
 0b11100000,
 0b11000000,
 0b10000000,
 0b00000000,
 ///////////18///////////
 0b11111111, // For each pattern in the sequence,
 0b00000000, // 1 = light on, 0 = off
 0b11111111, // Any combination of lights can be on or off
 0b00000000,
 0b11111111, // NB: Length of this list must be
 0b00000000, // the same as PATTERNLENGTH
 //////////////////
 */
};
 return patternArray[index];
 }
استازى ارجو منك خدمه ليه وللناس كلها هيستفيدو منها انك تشرحلنا البرنامج كاملاا من اول عباره للاخرقصدى تشرحلنا كل جمله انتا كتبها ولو في بديل ولو عايز اغير بلبنات الي هتغزى الد مثلا رقم 2 هخليه خرج ورقم 7 لمفتاح الفوليم اعمل اه والبرنامج الوشرح جزء واحد منه حتى نفهم الباقى بسهوله وبمازا انهى البرنامج حتى يعيد تشغيل البرنامج من الاول لان عندى برنامج لا يعيد البرامج كلها مش فاهم ليه ارستر الكهرباء عمل لمره واحده ولا يعيد التكرار من اول البرنامج
ارجو منكان لا تبخل علينا بعلمك الزى اعطاك الله اياه واسف على كثرة اسئلتى لك اخ عبدالله عزيز

احصائية الشكر والاعجاب - 1 شكراً, 0 عدم اعجاب, 1 اعجاب
شكراً F.Abdelaziz ( شكر العضو على هذه المشاركة )
اعجاب عبدالله حجازى ( أعجبته المشاركة )

الصورة الرمزية F.Abdelaziz
F.Abdelaziz
:: استاذ و مشرف قسم الالكترونيات ::
تاريخ التسجيل: May 2007
المشاركات: 6,894
نشاط [ F.Abdelaziz ]
قوة السمعة:328
قديم 10-03-2016, 06:46 PM المشاركة 5   
افتراضي


يرجى مراجعة الرابط التالى والذى يوجد عليه الشرج الكامل لبرمجة الميكروكونترولر pic بلغة السى مع المترجم ميكروسى برو

http://www.qariya.info/vb/showthread.php?t=182701

احصائية الشكر والاعجاب - 0 شكراً, 0 عدم اعجاب, 1 اعجاب
اعجاب عبدالله حجازى ( أعجبته المشاركة )

الصورة الرمزية gheas
gheas
:: مهندس متواجد ::
تاريخ التسجيل: May 2005
الدولة: https://t.me/pump_upp
المشاركات: 128
نشاط [ gheas ]
قوة السمعة:0
قديم 11-03-2016, 05:44 PM المشاركة 6   
افتراضي


جزاك الله خير

احصائية الشكر والاعجاب - 1 شكراً, 0 عدم اعجاب, 0 اعجاب
شكراً F.Abdelaziz ( شكر العضو على هذه المشاركة )
إضافة رد

العلامات المرجعية

«     الموضوع السابق       الموضوع التالي    »
أدوات الموضوع

الانتقال السريع إلى


الساعة معتمدة بتوقيت جرينتش +3 الساعة الآن: 01:06 AM
موقع القرية الالكترونية غير مسؤول عن أي اتفاق تجاري أو تعاوني بين الأعضاء
فعلى كل شخص تحمل مسئولية نفسه إتجاه مايقوم به من بيع وشراء وإتفاق وأعطاء معلومات موقعه
التعليقات المنشورة لا تعبر عن رأي موقع القرية الالكترونية ولايتحمل الموقع أي مسؤولية قانونية حيال ذلك (ويتحمل كاتبها مسؤولية النشر)

Powered by vBulletin® Version 3.8.6, Copyright ©2000 - 2024