Go Down

Topic: How to access TCNT1 (ATmega168)? (Read 2980 times) previous topic - next topic


Writing my first sketch.

I need to read the value of the 16-bit timer/counter TCNT1 and also at some later time reset it. Regarding set-up, full-speed (divide by 1) is fine (this is default?).

Is this supported in Arduino 0011? Do I need to INCLUDE (not sure how to do that) something in order to use TCNT1?

Examples would be appreciated, but not required http://www.arduino.cc/yabbfiles/Templates/Forum/default/wink.gif

Thanks in advance,


Include avr/io.h and then you can read/write directly to TCNT1, like so:

TCNT1 = 0;


Note that io.h is included automatically by the arduino build process.

 TCNT1 = 0;

will work without explicitly adding the include file.

Go Up