WGM12 is a bit, or position in the register, it's not '3' or number, rather a 'switch' in line of 16 others switches, which you could turn on or off. There is an extract, which show 16! different modes of timer settings.
Visit and download datasheet for your uCPU (depends on board, for UNO - AtMega328). Which makes B = 1111 0000, but in this example A is a series of 0s and 1s and the shifter is a decimal, but it isn’t the case in the code line, which is confusing me. Now I’m wondering what “1 << WGM12” means… I think I understand this: I know nothing about bitwise operators so I searched again and I found out it’s like: TCCR1B = TCCR1B | (1 << WGM12) I played with OCR1A to change frequency, but I really don’t get what this means (among other lines): TCCR1B |= (1 << WGM12) ISR(TIMER1_COMPA_vect) // timer compare interrupt service routineĭigitalWrite(ledPin, digitalRead(ledPin) ^ 1) // toggle LED pin
TIMSK1 |= (1 << OCIE1A) // enable timer compare interrupt Thanks, I searched the web for timer tutorials and found this interesting blog post: