Electrical Engineering
Electrical Engineering
EXPERIMENT NO 08
LAB ASSESSMENT:
Data presentation
Experimental results
Conclusion
Code:
void main() {
TrisD=0xFF; //Define PortD an input port
TrisB=0; //Define PortB an Output Port
while(1) //Infinite loop
{
LatB=PortD; //Input from the PortD is being written on LATB
}
}
Proteus Simulation:
Task 02:
Write a code to generate the pattern shown below on Led Bar graph.
Code:
void main(void){
TRISB=0x00;
while(1){
unsigned int x,y,z;
y=1;
for(z=1; z<=4; z++){
PORTB=x=y;
y=x*2;
Delay_ms(250);
}
for(z=3; z>= 0; z--){
PORTB=x=y/2;
y=x;
Delay_ms(250);
}
}
}
Proteus Simulation:
Task 03:
Code:
void main(void){
TRISC=0x00;
TRISD0_bit=0;
TRISD1_bit=0;
while(1){
unsigned int x;
Unsigned int z[]=
{0b1000000,0b1111001,0b0100100,0b0110000,0b0011001,0b0010010,0b0000010,0b1
111000,0b0000000,0b0011000};
PORTD.F0=1;
PORTD.F1=1;
for(x=0; x<10; x++){
PORTC=z[x];
Delay_ms(500);
}}}
Proteus Simulation:
Conclusion:
In this lab, we learned about the PIC18F452 and how to program it using C language and
MikroC program. We perform the above tasks and stimulated the result in Proteus software.
We are now familiar with the implementation of counter using PIC.
********