CIRCUIT:
Program:
#include<p18f452.h>
#pragma config WDT=OFF
#define a 50
void delay(unsigned char);
void main(){
TRISB=0x00;
while(1){
PORTB = 0b00000001;
delay(a);
PORTB = 0b00000100;
delay(a);
PORTB = 0b00000010;
delay(a);
PORTB = 0b00001000;
delay(a);
}
}
void delay(unsigned char time){
unsigned char i,j;
for(i=0;i<165;i++)
for(j=0;j<time;j++);
}
Program:
#include<p18f452.h>
#pragma config WDT=OFF
#define a 50
void delay(unsigned char);
void main(){
TRISB=0x00;
while(1){
PORTB = 0b00000001;
delay(a);
PORTB = 0b00000100;
delay(a);
PORTB = 0b00000010;
delay(a);
PORTB = 0b00001000;
delay(a);
}
}
void delay(unsigned char time){
unsigned char i,j;
for(i=0;i<165;i++)
for(j=0;j<time;j++);
}
Comments
Post a Comment