#include #include #include #define F_CPU 8000000UL // CPU Clock Frequency in Hz #define BAUD_RATE 9600 #define BAUD_RATE_DIVISOR ((F_CPU / (16UL * BAUD_RATE)) - 1) // Define segments for each digit #define A (1<= 0 && data <= 9 && currentDigit < 6) { digits[d] = data; d++; } // Echo back the received data while (!(UCSRA & (1 << UDRE))); // Wait for the transmit buffer to be empty UDR = data; // Send the received data back } int uart_putchar(char c, FILE *stream) { if (c == '\n') { uart_putchar('\r', stream); } // Wait for empty transmit buffer while (!(UCSRA & (1 << UDRE))); // Put data into buffer, sends the data UDR = c; return 0; } int main() { // Set PORTB as output for segments DDRB = 0xFF; // Set PORTA and PORTD as output for digit control DDRA |= (1<> 8); UBRRL = BAUD_RATE_DIVISOR; // Enable receiver and RX complete interrupt UCSRB |= (1<