Page 681 - 완) I MDP 프로젝트 작품 보고서(전체과 1학년)1.6
P. 681
void sub_On(void);
void sub_Off(void);
unsigned char data;
int state=0;
void main()
{
DDRE = 0xff; //전등
DDRA = 0xff; //선풍기
DDRB = 0xff; //가스벨브
UCSR1A = 0x00;
UCSR1B = 0b10010000;
UCSR1C = 0b00000110;
UBRR1H = 0;
UBRR1L = 103;
#asm("sei");
PORTA.0 = 0;
PORTB.3 = 0;
sub_Off();
while(1)
{
if(data == '1') PORTE.2 = 1;
else if(data == '2') PORTE.2 = 0;
else if(data == '3') PORTE.1 = 1;
else if(data == '4') PORTE.1 = 0;
else if(data == '5') PORTE.0 = 1;
else if(data == '6') PORTE.0 = 0;
else if(data == 'F') PORTA.1 = 1; //선풍기
else if(data == 'f') PORTA.1 = 0;
else if(data == 'G' && state == 0) sub_On(); //가스벨브
else if(data == 'g' && state == 1) sub_Off();
- 674 -