Skip to main content
added 80 characters in body
Source Link
Gerben
  • 11.3k
  • 3
  • 21
  • 34
#define INTERRUPTS 975

volatile uint8_t count;

if (count >= INTERRUPTS){

count is an 8 bit integer, so the maximum value of it is 255. Therefor count will never be bigger of equal to 975.

Use volatile uint16_t count; instead.

PS instead of messing with the TCNT0 register, I'd use 2 different values of INTERRUPTS to change between 15 and 5 second intervals.

Something like if( count>=975 || ( (col=='g'||col=='r') && count>=325 ) ){

#define INTERRUPTS 975

volatile uint8_t count;

if (count >= INTERRUPTS){

count is an 8 bit integer, so the maximum value of it is 255. Therefor count will never be bigger of equal to 975.

Use volatile uint16_t count; instead.

PS instead of messing with the TCNT0 register, I'd use 2 different values of INTERRUPTS to change between 15 and 5 second intervals.

#define INTERRUPTS 975

volatile uint8_t count;

if (count >= INTERRUPTS){

count is an 8 bit integer, so the maximum value of it is 255. Therefor count will never be bigger of equal to 975.

Use volatile uint16_t count; instead.

PS instead of messing with the TCNT0 register, I'd use 2 different values of INTERRUPTS to change between 15 and 5 second intervals.

Something like if( count>=975 || ( (col=='g'||col=='r') && count>=325 ) ){

Source Link
Gerben
  • 11.3k
  • 3
  • 21
  • 34

#define INTERRUPTS 975

volatile uint8_t count;

if (count >= INTERRUPTS){

count is an 8 bit integer, so the maximum value of it is 255. Therefor count will never be bigger of equal to 975.

Use volatile uint16_t count; instead.

PS instead of messing with the TCNT0 register, I'd use 2 different values of INTERRUPTS to change between 15 and 5 second intervals.