Hello everybody,
I am pretty new in pic microcontroller, I am creating a simple program by using micro-c
The is program consist of two LEDs
LED1 flashing on by 1sec.and off for 1sec
LED2 will be on directly if one button is pushed
But I got LED2 will be on after the delay time elapsed even( not directly)
I don’t know how can I overcome that
The code as in below:
define LED portb.f1
#define LED2 portb.f2
#define PB portb.f4
#define on 1
#define off 0
#define d1 delay_ms(1000)
#define d2 delay_ms(2000)
void main()
{
trisb.F1 = 0;
trisb.f2 = 0;
trisb.f4 = 1;
LED = off;
LED2 = off;
for(;
{
//push button program
if(PB == 1)
{
LED2 = on;
}
else
{
LED2 = off;
}
// Flash program
LED = on;
d1;
LED = off;
}
}
Thanks in advance
Moelsayed
I am pretty new in pic microcontroller, I am creating a simple program by using micro-c
The is program consist of two LEDs
LED1 flashing on by 1sec.and off for 1sec
LED2 will be on directly if one button is pushed
But I got LED2 will be on after the delay time elapsed even( not directly)
I don’t know how can I overcome that
The code as in below:
define LED portb.f1
#define LED2 portb.f2
#define PB portb.f4
#define on 1
#define off 0
#define d1 delay_ms(1000)
#define d2 delay_ms(2000)
void main()
{
trisb.F1 = 0;
trisb.f2 = 0;
trisb.f4 = 1;
LED = off;
LED2 = off;
for(;
{
//push button program
if(PB == 1)
{
LED2 = on;
}
else
{
LED2 = off;
}
// Flash program
LED = on;
d1;
LED = off;
}
}
Thanks in advance
Moelsayed