Hardware Reference
In-Depth Information
LED_status() function
This function determines the state of two green, red LEDs. If there are some vacant
spaces in the parking lot, the green LED is turned on. Otherwise the red LED is turned on
(blinking with a slow speed) to inform the next driver that parking area is already full. In
this case, if IR sensor detects any obstacle again, the red LED will blink at a faster rate.
if(capacity>0)
{
g_led=1;
r_led=0;
blink=0;
}
if((capacity==0)&&(input_sensor==0))
{
blink_time=140; / and 70 for fast blink/
g_led=0;
blink=1;
}
In above program code, the speed of red LED blinking can be changed by blink_time
variable. This variable is used in timer0 interrupt. In its interrupt function, the count vari-
able is incremented continuously, and when it reaches to blink_time value, if the blink
variable value equals 1, the state of red LED is inverted to show up a blinking LED
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
count++;
if(count>blink_time)
{
count=0;
if(blink==1)
Search WWH ::




Custom Search