# Need your help- A question about light control circuit using atmega8

Status
Not open for further replies.

#### bibiboo

##### Newbie level 4
I have some problems with my little project. I have made zero crossing detector circuit work well and use atmega8 to create a square ware base on the output of this circuit like in the picture below. However when i try to pass the signal to light control block ( with moc3021) errors appeared. Please help me! My deadline is comming. I attached my code using winavr and proteus here. Thanks first.
Code:
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>

void main (void)
{ DDRB = (1<<DDB0);
PORTB = (1<<PB0);
sei();
MCUCR = ( 1<< ISC00) | (0<<ISC01);
GICR |= (0<<INT0);
for(;;) {
if (GIFR&& (1<<INTF0)) { PORTB = (0<<PB0);
_delay_ms (4);
PORTB= (1<<PB0);
GIFR |= (1<<INTF0);}
}
}
View attachment test.zip

#### FvM

##### Super Moderator
Staff member
Only the timestep too small error needs your attention. It indicates an "everydays" SPICE convergence problem. Some hints can be found in the Proteus help. In general, you need to tune the simulator options respectively interactive simulation SPICE options.

Status
Not open for further replies.