#include #include "stdlib.h" // Load the ISRs: you need this #include "oulib_serial_buffered.h" int main(void) { // Initialize LEDs on pins 0 and 1 DDRB = 3; uint16_t counter = 0; PORTB = 1; delay_ms(250); PORTB = 2; delay_ms(250); PORTB = 3; delay_ms(250); PORTB = 0; delay_ms(1000); // Initialize the serial port FILE* fp0 = serial_init_buffered(0, 9600, 10, 10); char c; // Initialize interrupts (necessary for serial to work) sei(); printf("hello world\n\r"); while(1) { if(serial_buffered_input_waiting(fp0)) { // A character has arrived: do something with it c = getchar(); printf("%x:%c\n\r", c, c); // Toggle pin 1 PORTB ^= 2; // This delay allows us to test buffering //delay_ms(1000); } delay_ms(1); if(++counter == 100) { // Flip the state of the first LED. We get a 5Hz signal // on this pin counter = 0; PORTB ^= 1; }; }; }