باسلام
یه برنامه دارم چشمکزن دوتایه که به صورت کم و زیاد شدن ال ای دی ها کار میکنه وقتی ال ای دی اولی داره کا می کنه ال ای دی دومی نیمه روشنه به طور کامل خاموش نمیشه :angry: و وقتی ال ای دی دومی کار میکنه ال ای دی اولی نیمه روشنه دستور آف دادم ولی عمل نمکنه چرا؟؟ باتشکر ازهمه دوستان که کمک میکنن

#include <mega8.h>
# include <delay.h>
void main(void)
{
int x=0,h=0,a,b;
PORTB=0x00;
DDRB=0x06;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 1000.000 kHz
// Mode: Fast PWM top=00FFh
// OC1A output: Non-Inv.
// OC1B output: Non-Inv.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0xA1;
TCCR1B=0x0A;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
while (1)
{
while (h==0)
{
for(a=0;a<=1;a++)
{
for( x=0;x<=255;x++)
{
OCR1AL=x;
delay_ms(4);
}
for( x=255;x>=0 ;x--)
{
OCR1AL=x;
delay_ms(4);
}
if(a==1)
{
OCR1AL=0x0000;
h=1;
}
}
};
while(h==1)
{
for(b=0;b<=1;b++)
{
for( x=0;x<=255;x++)
{
OCR1BL=x;
delay_ms(4);
}
for( x=255;x>=0;x--)
{
OCR1BL=x;
delay_ms(4);
}
if(b==1)
{
OCR1BL=0x0000;
h=0;
}
}
}
};
}
یه برنامه دارم چشمکزن دوتایه که به صورت کم و زیاد شدن ال ای دی ها کار میکنه وقتی ال ای دی اولی داره کا می کنه ال ای دی دومی نیمه روشنه به طور کامل خاموش نمیشه :angry: و وقتی ال ای دی دومی کار میکنه ال ای دی اولی نیمه روشنه دستور آف دادم ولی عمل نمکنه چرا؟؟ باتشکر ازهمه دوستان که کمک میکنن

#include <mega8.h>
# include <delay.h>
void main(void)
{
int x=0,h=0,a,b;
PORTB=0x00;
DDRB=0x06;
// Timer/Counter 1 initialization
// Clock source: System Clock
// Clock value: 1000.000 kHz
// Mode: Fast PWM top=00FFh
// OC1A output: Non-Inv.
// OC1B output: Non-Inv.
// Noise Canceler: Off
// Input Capture on Falling Edge
// Timer 1 Overflow Interrupt: Off
// Input Capture Interrupt: Off
// Compare A Match Interrupt: Off
// Compare B Match Interrupt: Off
TCCR1A=0xA1;
TCCR1B=0x0A;
TCNT1H=0x00;
TCNT1L=0x00;
ICR1H=0x00;
ICR1L=0x00;
OCR1AH=0x00;
OCR1AL=0x00;
OCR1BH=0x00;
OCR1BL=0x00;
while (1)
{
while (h==0)
{
for(a=0;a<=1;a++)
{
for( x=0;x<=255;x++)
{
OCR1AL=x;
delay_ms(4);
}
for( x=255;x>=0 ;x--)
{
OCR1AL=x;
delay_ms(4);
}
if(a==1)
{
OCR1AL=0x0000;
h=1;
}
}
};
while(h==1)
{
for(b=0;b<=1;b++)
{
for( x=0;x<=255;x++)
{
OCR1BL=x;
delay_ms(4);
}
for( x=255;x>=0;x--)
{
OCR1BL=x;
delay_ms(4);
}
if(b==1)
{
OCR1BL=0x0000;
h=0;
}
}
}
};
}
دیدگاه