Assalamualaikum....
the work begin the new way to know the another type of basic coding such as look En Mazran blog.
Before this , me have a learn a little bit about Pic 16f877 on the lab session. Then, me look
the lab report such as , lab 3 :
#include <16f877a.h> //
declare file PIC16F877A
#use delay(clock=4000000) //
declare frequency internal oscillator, f=4MHz
#fuses hs,nowdt,nolvp,noprotect // declaration fuses for PIC function
#byte porta=5 //
declare address for port a=5
#byte portb=6 //
declare address for port b=6
#byte portc=7 //
declare address for port c=7
#byte portd=8 //
declare address for port d=8
void main () //
main function prototype
{
set_tris_b(0); // set all port
b pin is led output
set_tris_c(1); // set all port
c pin is switch input
set_tris_d(0); // set all port
d pin is output
while(true) // program
always loop
{
if(input(pin_c0)==1) //
if condition when pin C0, switch is high (1)
{
portb=0x01; // declare
output port b only pin LD1 is high
delay_ms(500); // frequency
for LED turn light
portb=0x02; // declare
output port b only pin LD2 is high
delay_ms(500);
portb=0x04; // declare
output port b only pin LD3 is high
delay_ms(500);
portb=0x08; // declare
output port b only pin LD4 is high
delay_ms(500);
portb=0x10; // declare
output port b only pin LD5 is high
delay_ms(500);
portb=0x20; // declare
output port b only pin LD6 is high
delay_ms(500);
portb=0x40; // declare
output port b only pin LD7 is high
delay_ms(500);
portb=0x80; // declare
output port b only pin LD8 is high
delay_ms(500);
}
Else //
else when pin C0, switch is low (0), opposite if condition
{
portb=0x80;
delay_ms(500);
portb=0x40;
delay_ms(500);
portb=0x20;
delay_ms(500);
portb=0x10;
delay_ms(500);
portb=0x08;
delay_ms(500);
portb=0x04;
delay_ms(500);
portb=0x02;
delay_ms(500);
portb=0x01;
delay_ms(500);
}
}
}
"Rome Was Not Built In One Day"
The idiom is show the working the much time on it , it comes its with successfully work.
No comments:
Post a Comment