imranahmed
Advanced Member level 3
- Joined
- Dec 4, 2011
- Messages
- 817
- Helped
- 3
- Reputation
- 6
- Reaction score
- 3
- Trophy points
- 1,298
- Location
- Karachi,Pakistan
- Activity points
- 6,492
Please let me know I have 89c52 and I want to program in this manner that counter counts by external interrupt by push button 0 to 500.
When it reaches 10 glow LED1 and at 15 glow LED2 at 25 glow LED1 again at 30 glow LED2 and so on till 500.
In above for 0 to 500 LED1 and LED2 glow alternatively with gap of 10 and 5.
I want to know is there any possibility for shorter code size.
When it reaches 10 glow LED1 and at 15 glow LED2 at 25 glow LED1 again at 30 glow LED2 and so on till 500.
Code:
unsigned int Counter = 0;
void ext0_isr(void) interrupt 0
{.
Counter++;
}
main()
{.
if(Counter == 10)
LED1 = 1;
else if(Counter == 15)
LED2 = 1;
else if(Counter == 25)
LED1 = 1;
and so on till 500
}
In above for 0 to 500 LED1 and LED2 glow alternatively with gap of 10 and 5.
I want to know is there any possibility for shorter code size.