Answer the question
In order to leave comments, you need to log in
What is the problem in the code?
#include <mega8.h>
#include <delay.h>
int z=0;
void main(void)
{
DDRB = 0b0000000;
PORTB = 0b0000001;
DDRD = 0b0000111;
PORTD = 0b0000000;
while (1)
{
if (PINB==0b0000000)
{
TCCR0 = 0b00000101;
TCNT0 = 0
while (z < 21)
{
if (TCNT0 == 255)
{
z++;
};
};
TCNT0 = 0;
TCCR0 = 0b00000000;
PORTD=0b00000111;
_delay_ms(1000)
};
if (PINB==0b0000001)
{
PORTD=0b00000000;
};
};
};
Answer the question
In order to leave comments, you need to log in
until z becomes 1024/1000000*255*20 seconds wait
while (z < 21) { if (TCNT0 == 255) { z++; }; };
Speaking in Russian, I pressed the button and waited for about 5.2 s
The code does not work in proteus and throws errors
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question