I'm trying to spoof a 433 MHz remote and I have a sequence of 32 bytes that I want to repeatedly shift out to one of ATtiny85's pins. The signal then goes to a cheap Chinese-type 433 Mhz transmitter. I utilized the built-in 8-bit Timer/Counter0. Unfortunately, in constant places in my sequence there are glitches in form of repeated bits. For example (byte no. 5): Bit number (starting from 0) 40 41 42 43 44 45 46 47 Correct 0 0 1 0 0 1 0 0 Actual 0 0 0 1 0 0 1 0 [![enter image description here][1]][1] [1]: https://i.sstatic.net/m4CD5.png My code: #include <avr/io.h> #include <avr/interrupt.h> #include <avr/sleep.h> #include <avr/pgmspace.h> #define OUT PB2 uint8_t bit = 0; // current bit const uint8_t data[32] PROGMEM = { 0b10101010, 0b10101010, 0b10101010, 0b00000000, 0b01001001, 0b00100100, 0b11010011, 0b01101101, 0b00110100, 0b10010011, 0b01001101, 0b10100110, 0b11010010, 0b01001101, 0b10100100, 0b10011010, 0b01101001, 0b10110110, 0b10011010, 0b01101101, 0b10110100, 0b11011011, 0b01101101, 0b10110110, 0b11011010, 0b01101101, 0b10110100, 0b11011010, 0b01101000, 0b00000000, 0b00000000, 0b00000000, }; int main() { DDRB |= _BV(OUT); TCCR0A |= _BV(WGM01); // clear timer on compare match TIMSK |= _BV(OCIE0A); // 2 kbps TCCR0B |= _BV(CS01); // prescaler: 8 OCR0A = 62; // timer counts to 62 instead of 255 sei(); while (1) { sleep_mode(); } } ISR (TIMER0_COMPA_vect) { if (pgm_read_byte(&(data[bit / 8])) & (1 << bit % 8)) { // read current bit from progmem array PORTB |= _BV(OUT); } else { PORTB &= ~_BV(OUT); } // I tried // if (bit == 255) bit = 0; else bit++; // but it made no difference, so i left it like this // because it's shorter bit++; // let it overflow } I wondered if somebody could help me to troubleshoot this or maybe propose a better solution to this task which is just shifting out bytes without a clock.