ISR(TIMER0_COMPA_vect) { countSelf++; // La fiecare threshold/100 secunde este pornit sunetul if (countSelf == threshold) { // Generare repetari audio audioRepeat = random(100, 200); // Reinitializarea count si threshold countSelf = 0; threshold = random(1000, 2000); } } void configure_timer0() { // Configurare pentru Timer 0 în mod CTC // Frecventa de 100 Hz -> 0.01 secunde TCCR0A = 0; TCCR0B = 0; TCNT0 = 0; OCR0A = 155; TCCR0A |= (1 << WGM01); // CTC mode TCCR0B |= (1 << CS00); TCCR0B |= (1 << CS02); } void init_timer0() { TIMSK0 |= (1 << OCIE0A); }