it's suppose to put led blinking, but it's not working, what i am doing wrong?
We have to know where the LED is connected.
We have to know what each of the steps in your sketch is attempting to achieve.
The information mentioned above is typically provided via 'comments'. I know it requires some effort to provide that information but why should you expect your helpers to do that work in addition to doing the troubleshooting that you request?
You state that the program is 'not working'. We have to know what it is supposed to do, in this case how often should the LED blink. We also have to know what it actually does. Is the LED always ON, always OFF, dim? When a program does not work as expected what it does do can often provide a clue to the problem.
but the problem is resolved, changed unsigned char cont to unsigned int cont and raised cont=2000, the led is blinking very fast that is impossible to see.
TIMSK0=0b00000100;
I think you have the wrong bit here.
I see that you are using Compare Match B, so this would be correct. I’m not sure about their interaction (between A and B), but I think you might have better luck starting out with Compare Match A.
It's much better with the comments! Here's one more tip:
DDRD=0x02; //pin 1 as output for led
OCR0B=77; //value which tcnt0 will compare
These two arguments are bitmapped, so the binary radix is more appropriate.
You might want to go to http://web.alfredstate.edu/weimandn. Scroll down to the "Atmel ATmega Subsystem Diagrams" section and follow the [u]Reference Diagrams[/u] link. There's no diagram for Timer/Counter0 Compare Match B (yet), but the one for Compare Match A is pretty close.
It's much better with the comments! Here's one more tip:
DDRD=0x02; //pin 1 as output for led
OCR0B=77; //value which tcnt0 will compare
These two arguments are bitmapped, so the binary radix is more appropriate.
You might want to go to http://web.alfredstate.edu/weimandn. Scroll down to the "Atmel ATmega Subsystem Diagrams" section and follow the Reference Diagrams link. There's no diagram for Timer/Counter0 Compare Match B (yet), but the one for Compare Match A is pretty close.
Don
thanks for the tips and link, the link is very useful, and contains diagrams that help me a lot to understand, i'm newbie, my friends told me that the arduinos is good thing for beginners like me. i don't know what is meaning of "bitmapped", but i will reasearch about this.
regards
ps. english is not my language, correct me, if i wrote something wrong, so i could improve my english.
First of all I misspoke when I said that OCR0B is bitmapped - it’s not, but DDRD is.
i don’t know what is meaning of “bitmapped”
‘Bitmapped’ means that each bit within the byte has a specific meaning but the numerical value of all the bits taken together probably does not.
Think about how you came up with the statement DDRD=2;. Where did the number ‘2’ come from? Would DDR2=0b00000010; make more sense? If you don’t know the answers let me know and I will give you more information.
english is not my language, correct me, if i wrote something wrong, so i could improve my english.
Your English is quite understandable but if you want to make the grammar better you would rephrase ‘i don’t know what is meaning of “bitmapped”’ to ‘I don’t know the meaning of “bitmapped”’.
DDRD=0x02; //pin 1 as output for led - here i could had written DDRD=0b00000010
TCCR0B=0b00000101; //prescaler 1024 and here i could had written TCCR0B=0x05
so if look it again another time, i could know that is possible to program in one way or another.
Somebody has to learn enough about programming to write these libraries. I got the impression that 'bsprit' might be one of those types.
Don
why you say that?
ps. for first impression i have, I'm really enjoying the forum, here have helpful people, it is pity not understand and write English well, making more difficult to reply well