أكواد للمساعدة :
كود:
/************ أبسط برنامج ****************
كتابة آحاد أى إضاءة جميع الليدات المتصلة بالمنفذ
Eng.F.Abdelazis
http://www.eeecb.com/vb/index.php
*****************************************/
void main () { // الدالة الرئيسية
TRISB= 0x00; // إعداد المنفذ كمخارج بتصفير جميع بتات سجل التحكم
PORTB = 0xFF; //;كتابة أو إرسال آحاد إلى جميع الأطراف
while (1);
}
كود:
/*********************************************************************
Program: Flashes
Objective: This program aims to flash all LED's on PORTB
1 second (on and off);
Using: while loop and delay function
Eng.F.Abdelaziz
http://www.eeecb.com/vb/index.php
******************************************************************* */
void main() // Main function
{ //Begin
TRISB = 0; // Set all PORTB as outputs
while(1){ //Infinit loop
PORTB = 0 ; // Clear all PORTB bits (Low)
delay_ms (1000); // Dlay 1000ms or 1 second compiler function compiler
PORTB = 255; // All BORTB High (1)
delay_ms (1000); // wait 1 second again
// Back for a while,the function always true
}
} //END
كود:
/*********************************************************************
Program: Flashes
Objective: This program aims to flash the LED's on PORTB
1 second (on and off);
Using inverse operator (~)
Eng.F.Abdelaziz
http://www.eeecb.com/vb/index.php
******************************************************************* */
void main( )
{
TRISB = 0; // Set all PORTB bits as output
PORTB = 0; // Clear all pins on PORTB
while (1) { // Condition of the infinite loop
PORTB = ~ PORTB; // inverse the state of All PORTB bits
delay_ms (1000); // delay of 1000 milliseconds (one second)
}
}
كود:
/*********************************************************************
Program: Led عداد
Objective:PORTB إنشاء عداد ثنائى باستخدام المنفذ
Use: التزايد بواحد
Eng.F.Abdelaziz
http://www.eeecb.com/vb/index.php
****************************************************************** */
void main( )
{
int a;
TRISB = 0; // set PORTB as output
PORTB = 0 ; // Clear all pins of PORTB
while (1) { // condition of the infinite loop
PORTB = PORTB + 1 ; // increase 1
delay_ms (1000) ; // delay of 1000 milliseconds
}
}
كود:
/*********************************************************************
Program: Flash
Objective: إنشاء نموذج إضاءة بسيط
Using: الأعداد الثنائية
Eng.F.Abdelaziz
******************************************************************* */
void main() {
TRISB = 0; // set PORTB as output
while(1){
PORTB = 0b10101010; // نموذج إضاءة المخارج الزوجية
delay_ms (1000); // 1000ms or 1 second
PORTB = 0b01010101; // نموذج إضاءة المخارج الفردية
delay_ms (1000); // wait 1 second again
}
}
كود:
/*********** التعامل مع البتات **********
Eng.F.Abdelaziz
http://www.eeecb.com/vb/index.php
**********/
void main () {
TRISB.B0 = 0; // set pin RB0 as output
while (1) { // condition of infinite loop
PORTB.B0 = 1;
delay_ms (1000); // delay of 1000 milliseconds (one second)
PORTB.B0 = 0;
delay_ms (1000); // delay of 1000 milliseconds (one second)
}
}