/* * RS232_Send.c * * Created: 9/10/2015 9:25:23 pm * Author : Dimitrios Porlidas */ #include #include //#define F_CPU 8000000UL unsigned char name[] = {'D','i','m','i','t','r','i','o','s',' ','P','o','r','l','i','d','a','s',10,13}; unsigned char i; void USART_Init( unsigned int baud ) // Initialization routine { UBRRH = (unsigned char)(baud>>8); // Set baud rate UBRRL = (unsigned char)baud; // UCSRB = (1<9600, 34->14400, 25->19200, 16->28800*, 12->38400, 8->57600, 6->76800, 3->115200** (*Error magnitude) while (1) { while ((PINC == 0b11111110) | (PINC == 0b11111101)) // Check buttons 0 & 1 { _delay_ms(10); switch (PINC) // command "switch" example { case 0b11111110: // Button 0 pressed for (i = 0; i < 20; i++) // { // _delay_us(10); USART_Transmit(name[i]); // Send my name // } while (PINC == 0b11111110); // Wait if button is still pressed break; case 0b11111101: // Button 1 pressed USART_Transmit(12); // Clear screen while (PINC == 0b11111101); // Wait if button is still pressed break; } } } }