ArdyNT
Full Member level 2
- Joined
- Nov 6, 2012
- Messages
- 126
- Helped
- 7
- Reputation
- 14
- Reaction score
- 7
- Trophy points
- 1,298
- Activity points
- 2,304
I'm using external interrupt to make three blinking LEDs with different delay. The idea is when interrupt occurs, then all LED will start blinking at the same time but with different delay. I've tried it using 1 LED only and it work well. Now I need help to make it three. for example 1st LED blinking with 1s delay, 2nd LED 3s, 3rd LED 5s. I'm using codevisionavr and this is the part of my code.
Help me please coz I'm very new here.
Thank you.
Code:
// External Interrupt 0 service routine
interrupt [EXT_INT0] void ext_int0_isr(void)
{
// Place your code here
delay_ms(1000);
PORTB.0=0;
delay_ms(1000);
PORTB.0=1;
}
#define ADC_VREF_TYPE 0x40
// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}
// Declare your global variables here
void main(void)
{
// Declare your local variables here
PORTB=0x07;
DDRB=0xFF;
// External Interrupt(s) initialization
GICR|=0x40;
MCUCR=0x02;
MCUCSR=0x00;
GIFR=0x40;
// Global enable interrupts
#asm("sei")
while (1)
{
}
}
Help me please coz I'm very new here.
Thank you.