#include <avr/io.h>//input output
#define F_CPU 16000000UL//kecepatan clock
int main() {
// put your setup code here, to run once:
DDRB |= (1 <<PINB5);//Set PINB5 1(sebagai output) memanfaat
while(1) {
PORTB |= (1 <<PINB5);
delay_ms(1000);
PORTB &= ~(1 <<PINB5);
delay_ms(1000);
}
return 0;
}
void delay_ms(uint16_t milliseconds) {
while(milliseconds) {
// Mengatur prescaler 64 untuk timer1 (16-bit timer) untuk periode 1 ms
TCCR1B |= (1 << CS11) | (1 << CS10); // Prescaler 64
TCNT1 = 0; // Reset counter value
while (TCNT1 < 125); // Timer akan menghitung sebanyak 125 siklus untuk 1 ms pada prescaler 64
milliseconds--;
}}