Use proteus circuit of 7-segment Lab, apply switch at RB0. When switch is pressed your lab group name should be displayed otherwise counting should carry on.
/*Use proteus circuit of 7-segment Lab, apply switch at RB0. When switch is pressed
your lab group name should be displayed otherwise counting should carry on.*/
unsigned int i;
unsigned int seg[]={0X3F, //Hex value to display the number 0
0X06, //Hex value to display the number 1
0X5B, //Hex value to display the number 2
0X4F, //Hex value to display the number 3
0X66, //Hex value to display the number 4
0X6D, //Hex value to display the number 5
0X7C, //Hex value to display the number 6
0X07, //Hex value to display the number 7
0X7F, //Hex value to display the number 8
0X6F, //Hex value to display the number 9
}; //End of Array for displaying numbers from 0 to 9
void main() //Main Service Routine
{
TRISD = 0; // To configure PORTD as output port
OPTION_REG.INTEDG = 1; // Set Rising Edge Trigger for INT
INTCON.GIE = 1; // Enable The Global Interrupt
INTCON.INTE = 1; // Enable INT
while(1) //forever
{
for(i=0; i<10; i++)
{
PORTD = seg[i];
delay_ms(1000); // Delay for 1 sec
}
}
}
void interrupt() // ISR
{
INTCON.INTF=0; // Clear the interrupt 0 flag
PORTD = 0x77; //Hex value to display the number A
delay_ms(2000); // Delay for 1 sec
PORTD = 0X06; //Hex value to display the number 1
delay_ms(3000); // Delay for 1 sec
PORTD = 0x00; //Display Off
}
Comments
Post a Comment