I build a dimmer using phase firing control and the result is in picture below. I use AVR GCC to compile this code:
#define F_CPU 12000000UL #include#include #include void delayms(uint16_t millis) { while (millis) { _delay_ms(1); millis--; } } void delayus(uint16_t micros) { while (micros) { _delay_us(1); micros--; } } int main(void) { DDRB=0x01; DDRD=0x00; // PD2 (INT0 pin) is now an input MCUCR |= (1 << ISC01); // Falling edge GICR |= (1 << INT0); // Turns on INT0 sei(); // turn on interrupts while (1) {} return 0; } ISR (INT0_vect) { PORTB=0x00; delayms(5); // 50% brightness PORTB=0x01; // delayus(10); // firing pulse width 10us PORTB=0x00; }
Why the green wave does not change? even I vary the delay time (1 until 9ms), it still look like that.
Pls guide me to solve my problem?