#include #include #include //variables define portio PIND #define portiow PORTD #define rxled PD7 #define rele PD6 #define btnsw PD5 #define triac PD4 #define MAX_BUFFSIZE 3 #define TRUE 1 #define FALSE 0 unsigned char receiveChar(void ) { unsigned char ch = UDR; return ch; } void sendChar(char data) { while( !(UCSRA&(1<>8); UBRRL = (unsigned char) ubrr; sei(); // Enable interrupts } /* short int usart_val = 0; //value for usart address validity volatile unsigned int usartin = 0; //value for usart character volatile unsigned char usart[3]; volatile unsigned char usart1[3]; int usart2[3]; int usart3[3]; */ volatile unsigned char usart1[MAX_BUFFSIZE]; unsigned char rx_count = 0; volatile unsigned char GotMessage = FALSE; short int ovf0cnt = 0; //value for timer0 cycle short int int0cnt = 0; volatile unsigned int timer = 0; volatile unsigned char timer_flag = FALSE; short int i = 0; //value for pwm storing volatile short int btnsw_right = 0; int count = 0; int main (void) { TIMSK |= (1<= 4500) && (timer_flag == TRUE)) { //portiow ^= (1 << rxled); OCR2 = 0xFF; if(usart1[1] == '3') portiow |= (1 << rele); else if(usart1[1] == '4') portiow &= ~(1 << rele); timer = 0; timer_flag = FALSE; } } ISR(USART_RXC_vect) { if((rx_count < MAX_BUFFSIZE) && RXC && !GotMessage) { usart1[rx_count++] = receiveChar(); if(rx_count == MAX_BUFFSIZE) { sendChar(usart1[1]); //portiow ^= (1 << rxled); GotMessage = TRUE; } } }