Smart Home 1. Embeded UART 2. GoAhead Web Server 3. JQuery, JQTouch 4. AJAX 5. JK-FF Switch 강의명 : 담당교수 : 임베디드소프트웨어및실습 고진석교수님 전공 : 전자공학과 실습조 : 학번 / 성명

Similar documents
PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

슬라이드 1

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

K&R2 Reference Manual 번역본

PowerPoint 프레젠테이션

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202834C1D6C2F7207E2038C1D6C2F729>

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

UART.h #ifndef _UART_H_ #define _UART_H_ #define DIR_TXD #define DIR_RXD sbi(portd,4) cbi(portd,4) #define CPU_CLOCK_HZ UL UART PORT1 void UAR

untitled

PowerPoint 프레젠테이션

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A634C0CFC2F72E BC8A3C8AF20B8F0B5E55D>

T100MD+

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202834C1D6C2F7207E2038C1D6C2F729>

KEY 디바이스 드라이버

MAX232 MAXIM사에서생산되는 RS-232통신을가능토록해주는송수신 IC이다. 송수신드라이브를각각 2개씩가지고있다. AVR과컴퓨터가인식하는 0과 1의값이다르기때문에.. 마이컴컴퓨터 이차이를해결해주는것이다. 0 0V -10V 1 5V 10V TTL IC 의전원단자와다

M16_32KIT_Manual.hwp

chap7.key

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A638C0CFC2F72E BC8A3C8AF20B8F0B5E55D>

<4D F736F F F696E74202D20B8B6C0CCC5A9B7CEC7C1B7CEBCBCBCAD202839C1D6C2F7207E203135C1D6C2F >

<4D F736F F F696E74202D20BBB7BBB7C7D15F FBEDFB0A3B1B3C0B05FC1A636C0CFC2F72E BC8A3C8AF20B8F0B5E55D>

교육지원 IT시스템 선진화

슬라이드 1

ATmega128

C++-¿Ïº®Çؼ³10Àå

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

/chroot/lib/ /chroot/etc/

PowerPoint 프레젠테이션

Chapter. 14 DAC 를이용한 LED 밝기제어 HBE-MCU-Multi AVR Jaeheung, Lee

vi 사용법

[8051] 강의자료.PDF

lecture4(6.범용IO).hwp

5.스택(강의자료).key

Microsoft PowerPoint - lab14.pptx

Motor

Microsoft PowerPoint - AVR 시리얼 통신.ppt [호환 모드]

본 강의에 들어가기 전

bn2019_2

Ext JS À¥¾ÖÇø®ÄÉÀ̼ǰ³¹ß-³¹Àå.PDF


2. GCC Assembler와 AVR Assembler의차이 A. GCC Assembler 를사용하는경우 i. Assembly Language Program은.S Extension 을갖는다. ii. C Language Program은.c Extension 을갖는다.

C H A P T E R 2

Microsoft Word doc

À©µµ³×Æ®¿÷ÇÁ·Î±×·¡¹Ö4Àå_ÃÖÁ¾

untitled

컴파일러

歯9장.PDF

인터럽트 * 인터럽트처리메커니즘 ATmega128 인터럽트 2

Chapter #01 Subject

좀비프로세스 2

가. 도트매트릭스제어하기 단일 LED와는다르게도트매트릭스를구동시는구동전류가프로세서에서출력되는전류보다사용량을더많이필요하기때문에 TTL 계열의 IC로구동시키기에는무리가따른다. 이러한문제를해결하기위해서사용전압, 전류정격이높은달링턴트랜지스터가어레이형태로들어있는 ULN2803을

6주차.key

untitled

<443A5C4C C4B48555C B3E25C32C7D0B1E25CBCB3B0E8C7C1B7CEC1A7C6AE425CBED0C3E0C7C1B7CEB1D7B7A55C D616E2E637070>

1장. 유닉스 시스템 프로그래밍 개요

제1장 Unix란 무엇인가?

<4D F736F F F696E74202D20B8AEB4AABDBA20BFC0B7F920C3B3B8AEC7CFB1E22E BC8A3C8AF20B8F0B5E55D>

[ 융합과학 ] 과학고 R&E 결과보고서 뇌파를이용한곤충제어 연구기간 : ~ 연구책임자 : 최홍수 ( 대구경북과학기술원 ) 지도교사 : 박경희 ( 부산일과학고 ) 참여학생 : 김남호 ( 부산일과학고 ) 안진웅 ( 부산일과학고 )

1. 제품소개 그림. 1.1 이란? DC 모터구동시하드웨어제작에소요되는시간을단축시켜프로그래밍연구개발및학습효과를극대화시켜주는 입니다. 또한당사 DEV 보드와 1P 점퍼클립케이블을이용하여연동이가능하며, 산업용 DC 모터의정회전, 역회전구동및속도제어시유용하게사용되는 입니다.

Chapter_06

중간고사

UI TASK & KEY EVENT


03장.스택.key

BMP 파일 처리

PowerPoint 프레젠테이션

2주차: 입출력 제어 복습

Microsoft PowerPoint - chap13-입출력라이브러리.pptx

< E20C6DFBFFEBEEE20C0DBBCBAC0BB20C0A7C7D12043BEF0BEEE20492E707074>

프로그램을 학교 등지에서 조금이라도 배운 사람들을 위한 프로그래밍 노트 입니다. 저 역시 그 사람들 중 하나 입니다. 중고등학교 시절 학교 도서관, 새로 생긴 시립 도서관 등을 다니며 책을 보 고 정리하며 어느정도 독학으르 공부하긴 했지만, 자주 안하다 보면 금방 잊어

Microsoft PowerPoint - [2009] 02.pptx

10.

제12장 파일 입출력

인터럽트 (Interrupt) 범용입출력포트에서입출력의내용을처리하기위해매번입출력을요구하는플래그를검사하는일 (Pollong) 에대하여마이크로컨트롤러에게는상당한시간을소비하게만든다. 인터럽트란 CPU가현재처리하고있는일보다급하게처리해야할사건이발생했을때, 현재수행중인일을중단하고

11장 포인터

도 1 명세서 도면의 간단한 설명 도 1은 본 발명의 바람직한 실시예에 따른 데이터 송수신 장치의 회로도이다. 도 2는 도 1에 도시된 등화기의 일 실시예를 보여주는 회로도이다. 도 3은 도 1에 도시된 프리엠퍼시스 회로의 일 실시예를 보여주는 회로도이다. 도 4는 본

MicrocontrollerAcademy_Lab_ST_040709

Microsoft PowerPoint - es-arduino-lecture-03

PowerPoint 프레젠테이션

제1장 Unix란 무엇인가?

untitled

MPLAB C18 C

Microsoft Word - KPMC-400,401 SW 사용 설명서

2009년 상반기 사업계획

Microsoft PowerPoint - 9.Serial.pptx

2 PX-8000과 RM-8000/LM-8000등의 관련 제품은 시스템의 간편한 설치와 쉬운 운영에 대한 고급 기술을 제공합니다. 또한 뛰어난 확장성으로 사용자가 요구하는 시스템을 손쉽게 구현할 수 있습니다. 메인컨트롤러인 PX-8000의 BGM입력소스를 8개의 로컬지

hd1300_k_v1r2_Final_.PDF

한글사용설명서

Transcription:

Smart Home 1. Embeded UART 2. GoAhead Web Server 3. JQuery, JQTouch 4. AJAX 5. JK-FF Switch 강의명 : 담당교수 : 임베디드소프트웨어및실습 고진석교수님 전공 : 전자공학과 실습조 : 학번 / 성명 : 5 조 2009160184 하성주 2010161002 전익현 제출일 : 2013. 12. 13

목차 1. 서론 1.1 연구 / 개발목적 1.2 요구사항 2. 구현방법 2.1 개념도 2.2 제품설계 2.3 웹설계 2.4 SM3-SV210 프로그램설계 2.5 디바이스설계 2.6 하드웨어설계 3. 동작확인 4. 고찰

1. 서론 1.1 연구 / 개발목적 스마트홈이란인터넷기반의정보화가생활속에깊숙히자리잡은요즈음에이르러단순한가정내네트워크의연결이아닌주택 ( 건물 ) 내의정보기술요소를구현하는토탈홈정보제어시스템및서비스 / 솔루션을총칭하는개념이다. 스마트홈은물리적보안, 센서, 스토리지, HostPC, 음성인식, 텔레매틱스, DTV 등다양한산업분야를융합한복합산업이며, 산업간파급효과가큰가치사슬을통해지속적으로부가가치를창출할수있는신성장산업이다. 본연구에서는한백전자의 HBE-SMⅢ-SV210 키트를이용하여스마트홈의가장기본이라고할수있는원격제어 / 보안서비스를만들어본다. 1.2 요구사항 인터넷을통해집의가전제품 / 조명등을원격제어할수있다. PC뿐만아니라스마트폰 ( 안드로이드, 아이폰포함 ) 에서자유롭게사용가능해야한다. 호환되는가전제품에서만사용되는것이아니라범용적으로, 간단한장치의설치만으로도가정에서직접사용할수있어야한다. 기존의사용방법 ( 수동으로제어 ) 으로도가전제품을제어할수있고, 동시에인터넷으로도제어가능해야한다. 현재가전제품의상태를실시간으로원격에서알수있어야한다. 2. 구현방법 2.1 개념도 1사용자 UI 제공 JQuery와 JQTouch를이용해스마트폰의앱과비슷한 UI를가진웹어플리케이션을만들수있다. 2인터넷접속한백전자 SDK는베이스보드를통해이더넷인터페이스를제공하여인터넷에접속할수있다.

3실시간모니터링 AJAX 기술을통해비동기적으로디바이스의상태를받아갱신하여실시간으로사용자에게보여진다. 4웹서버리눅스기반의 GoAhead 웹서버를통해한백전자 SDK를이용웹서비스가가능하며, CGI를통해사용자가원하는서비스를제공한다. 5UART통신한백전자 SDK는두개의 USART 단자를제공하며, 이를통해다른디바이스와 USART통신을할수있다. 2.2 제품설계 본프로젝트에서는구현의편의상가전제품을 LED 로대체하여구현하였다. 2.3 웹설계 HTML 과 AJAX 를통해실시간성을띄며, JQuery 와 JQTouch 를통해깔끔한이미지를구현할 수있다. 메인화면 DashBoard 화면

Control Panel 화면 거실 Switch About 화면 2.4 SM3-SV210 프로그램설계 디바이스와통신하기위해리눅스의 UART디바이스드라이버 ttysac2를사용하였으며, 출력된값을 HEX형태로받아와비트단위로판별하여사용한다. 웹에서사용할수있도록 CGI의형태로사용되며, 디바이스와통신하며웹상에서서비스를제공하게된다. 이번에제작한서비스는각가전제품의상태를알려주고, 각가전제품의상태를제어 (On/Off) 하는기능을가진다.

2.5 디바이스설계 설계의방법은 ATMEGA128 을이용하여구현하였으며, 디바이스가 H/W 포트출력을지속적으 로읽어 USART 로출력하고, USART 로입력이들어온다면인터럽트루틴으로들어가장치를제 어한뒤복귀한다. 2.6 하드웨어설계 JK플립플롭을이용해현재의상태를기억하며, 스위치입력 ( 클럭펄스 ) 을이용해 J-K를묶은곳에넣어주면, 플립플롭의출력을반전시킬수있다. JK 플립플롭은 HD74LS76AP를사용하였고, HD74LS76AP에는두개의플립플롭이들어있으므로, 회로를두개씩묶어서제작하였다. C1015 트랜지스터는릴레이를구동시키기위한증폭용으로사용하였다.

3. 동작확인 완성된하드웨어 수동 Switch On / OFF

상태창확인 거실 Switch On

상태창바뀐화면 (LIVING ROOM OFF -> ON) 4. 결론 이번임베디드의프로젝트는기존과목들의프로젝트와는다르게리눅스환경에서의개발뿐아니라마이크로프로세서Ⅱ과목에서배웠던 ATMEGA128과이전에수업을통해배워보지못한 HTML을통한웹서버를구축함으로서, 다양한기술들을융합하고조합을시킨프로젝트이다. 물론지금까지의프로젝트와는새로운방법을사용하였기때문에많은수많은시행착오를하였다. 서로규격이다른통신을하기위한프로토콜구축과이전에해보지못하였던 JQuery 와 JQTouch 그리고현상태를실시간으로확인하기위한 AJAX등의기술들을사용하면서어려움도많았지만그만큼많은것들을배울수있던좋은기회였다. 다만아쉬운적이있다면, 통신의방식에너무많은신경을썼기때문에동작여부를확인할수있는방법을단순하게 LED를사용하였던것이매우아쉽긴하지만, 많은기술들을직접구현하여사용해보았다는것에큰의미가있는것같다. 또한앞으로취업을준비함에있어서앞으로발전할기술인스마트홈을직접만들어보고제어해본경험은학창시절에서잊지못할경험중하나로남을것이라고생각이되며, 이번프로젝트를통해서나만의커리어를만들수있게된것같다. 앞으로기술이더욱발전을하여실생활에서더욱발전된모습의스마트홈에서생활을할수있었으면좋겠다.

5. 코드 5.1. CGI 코드 #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/ioctl.h> #include <termios.h> #include <fcntl.h> #include <string.h> #include <ctype.h> typedef struct char name[128]; char val[128]; entry; //UART int uart_dev; struct termios oldtio,newtio,new_key_tio,old_key_tio; void init_uart(void) uart_dev = open("/dev/ttysac2",o_rdwr O_NOCTTY); if(uart_dev < 0) perror("/dev/ttysac2"); printf("init error"); exit(1); tcgetattr(uart_dev,&oldtio); bzero(&newtio,sizeof(newtio)); newtio.c_cflag = B9600 CS8 CLOCAL CREAD; newtio.c_iflag = IGNPAR ICRNL; newtio.c_oflag = 0; newtio.c_lflag = ~(ICANON ECHO ECHOE ISIG); newtio.c_cc[vintr] = 0; newtio.c_cc[vquit] = 0; newtio.c_cc[verase] = 0; newtio.c_cc[vkill] = 0; newtio.c_cc[veof] = 0; newtio.c_cc[vtime] = 0; newtio.c_cc[vmin] = 0; newtio.c_cc[vswtc] = 0; newtio.c_cc[vstart] = 0;

newtio.c_cc[vstop] = 0; newtio.c_cc[vsusp] = 0; newtio.c_cc[veol] = 0; newtio.c_cc[vreprint] = 0; newtio.c_cc[vdiscard] = 0; newtio.c_cc[vwerase] = 0; newtio.c_cc[vlnext] = 0; newtio.c_cc[veol2] = 0; tcflush(uart_dev,tciflush); tcsetattr(uart_dev,tcsanow,&newtio); void close_uart(void) tcsetattr(uart_dev,tcsanow,&oldtio); close(uart_dev); void getword(char *word, char *line, char stop) int x =0, y = 0; for(x=0;((line[x]) && (line[x]!= stop)); x++) word[x] = line[x]; word[x] = '\0' if(line[x]) ++x; while(line[y++] = line[x++]); //printf("word : %s<br/>",word); //printf("line : %s<br/>",line); // 지정한정수에서, 몇번째비트만읽어서반환하는함수 //int getabit(unsigned short x, int n) // getbit() // return (x & (1 << n)) >> n; // int main(int argc, char **argv) char *cl; char ch; unsigned short val; entry entries; struct termios options; char buf[1]; char buff[1024];

int n, i; unsigned short data; int len; unsigned short mask = 0x01; // 비교시사용할숫자 printf("content-type: text/html\n\n"); init_uart(); memset(buff, 0x00, 1024); while((n = read(0, buff, 1023)) > 0) //printf("post DATA : %s</br>", buff); cl = (char*)buff; //cl = (char *)getenv("query_string"); //printf("data : %s", cl); getword(entries.name,cl,'='); getword(entries.val,cl,'&'); //printf("<br/>entries.name:%s",entries.name); //printf("<br/>entries.val:%s<br/>",entries.val); val = (unsigned short)strtol(entries.val,null,16); //printf("<br/>val:%02x<br/>",val); if(val == 0) ch = entries.val[0]; //printf("<br> ch : %02c </br>",ch); printf("<div> <h3> <center> STATE </center> </h3>"); printf("<p><center>---------------------------------</center></p>"); //printf("1"); len = read(uart_dev,buf,sizeof(buf)); while(!len>0) len = read(uart_dev,buf,sizeof(buf)); //printf("2"); if(len > 0) //printf("%02x\n",buf[0]); data = (unsigned short)buf[0]; //printf("%02x\n",data); //printf("<input type='hidden' id='result' value='"); //printf("data: %s <br/>",buf[0]); //printf("3");

//if((data&0b10000000)==0b10000000) printf(" 거실OFF\n"); else printf(" 거실ON\n"); //if((data&0b01000000)==0b01000000) printf("off"); else printf("tv ON"); //if((data&0b00100000)==0b00100000) printf("off"); else printf(" 도어락ON"); if((data&0b00010000)==0b00010000) printf("<p><center>livingroom OFF </center> </p>"); else printf("<p><center>livingroom ON</center> </p>"); if((data&0b00001000)==0b00001000) printf("<p><center>tv OFF</center> </p>"); else printf("<p><center>tv ON</center> </p>"); if((data&0b00000100)==0b00000100) printf("<p><center>door OFF</center> </p>"); else printf("<p><center>door ON</center> </p>"); if((data&0b00000010)==0b00000010) printf("<p><center>alarm OFF</center> </p>"); else printf("<p><center>alarm ON</center> </p>"); if((data&0b00000001)==0b00000001) printf("<p><center>gas OFF</center> </p>"); else printf("<p><center>gas ON</center> </p>"); printf(""); if(ch =='Q') //printf("<html><head> </head><body> <script>alert('back') history.go(-1); </script> </body> <html>"); //printf("<br/>q<br/>"); write(uart_dev,"q",1); if(ch =='W') //printf("<br/>w<br/>"); write(uart_dev,"w",1); if(ch =='E') write(uart_dev,"e",1); //printf("<br/>e<br/>"); if(ch =='R') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"r",1); //printf("<br/>r<br/>"); if(ch =='T') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"t",1); //printf("<br/>t<br/>"); if(ch =='Y') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"y",1); //printf("<br/>y<br/>");

if(ch =='U') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"u",1); //printf("<br/>u<br/>"); if(ch =='I') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"i",1); //printf("<br/>i<br/>"); if(ch =='q') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"q",1); //printf("<br/>q<br/>"); if(ch =='w') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"w",1); //printf("<br/>w<br/>"); if(ch =='e') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"e",1); //printf("<br/>e<br/>"); if(ch =='r') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"r",1); //printf("<br/>r<br/>"); if(ch =='t') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"t",1); //printf("<br/>t<br/>"); if(ch =='y') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"y",1); //printf("<br/>y<br/>"); if(ch =='u') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"u",1);

//printf("<br/>u<br/>"); if(ch =='i') printf("<html> \n <head> </head>\n<body>\n <script> location.reload(); </script> \n</body>\n <html>"); write(uart_dev,"i",1); //printf("<br/>i<br/>"); close_uart(); return 0; 5.2. 웹어플리케이션소스 (Jquery, Jqtouch, AJAX) <!DOCTYPE html> <html> <head> <title>smart Home</title> <link type="text/css" rel="stylesheet" media="screen" href="/jqtouch/jqtouch.css"> <link type="text/css" rel="stylesheet" media="screen" href="/themes/jqt/theme.css"> <script type="text/javascript" src="/jqtouch/jquery.js"></script> <script type="text/javascript" src="/jqtouch/jqtouch.js"></script> <script type="text/javascript" src="/kilo.js"></script> </SCRIPT> </head> <body> <div id="home"> <div class="toolbar"> <h1>smart Home</h1> <ul class="edgetoedge"> <li class="arrow"><a href="#dashboard">dash Board</a></li> <li class="arrow"><a href="#control">control Panel</a></li> <li class="arrow"><a href="#about">about</a></li> </ul> <div id="dashboard"> <div class="toolbar"> <h1>dashboard</h1> <a class="button back" href="#">back</a> <div> <form id = "form20" action = "cgi-bin/index.cgi" method = "POST" class = "form"> <ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="xx" id="xx" value = "gosil20">state</a> <input type="hidden" name="x" id="x" value = "x" /></li>

</ul> </form> <div id="about"> <div class="toolbar"> <h1>about</h1> <a class="button back" href="#">back</a> <div> <h3>smart Home</h3> <p>smart Home makes Your Home smarter!</p> <p>koreatech. 2013</p> <p>electronics Engineering / Embedded System</p> <div id="control"> <div class="toolbar"> <h1>control Panel</h1> <a class="button back" href="#">back</a> <ul class="edgetoedge"> <li class="arrow"><a id="r0" href="#control0"> 거실 </a></li> <li class="arrow"><a id="r1" href="#control1">tv </a></li> <li class="arrow"><a id="r2" href="#control2"> 도어락 </a></li> <li class="arrow"><a id="r3" href="#control3"> 경보기 </a></li> <li class="arrow"><a id="r4" href="#control4"> 가스밸브 </a></li> </ul> <div id="control0"> <div class="toolbar"> <h1> 거실 </h1> <a class="button cancel" href="#">cancel</a> <form id = "form1" action = "cgi-bin/index.cgi" method = "POST" class = "form"> <ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="br" id="br" value = "gosil1"> 거실OFF</a> <input type="hidden" name="r" id="r" value = "R" /></li> </ul> </form> <form id = "form2" action = "cgi-bin/index.cgi" method = "POST" class = "form"> <ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="br" id="br" value = "gosil2"> 거실ON</a>

<input type="hidden" </ul> </form> name="r" id="r" value = "r" /></li> <div id="control1"> <div class="toolbar"> <h1>tv</h1> <a class="button cancel" href="#">cancel</a> <form id = "form3" action = "cgi-bin/index.cgi" method = "POST" class = "form"> <ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="bt" id="bt" value = "TV1">TV OFF</a> <input type="hidden" name="t" id="t" value = "T" /></li></ul> </form> <form id = "form4" action = "cgi-bin/index.cgi" method = "POST" class = "form"> <ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="bbt" id="bbt" value = "TV2">TV ON</a> <input type="hidden" name="t" id="t" value = "t" /></li> </ul> </form> <div id="control2"> <div class="toolbar"> <h1> 도어락 </h1> <a class="button cancel" href="#">cancel</a> <form id = "form5" action = "cgi-bin/index.cgi" method = "POST" class = "form"> <ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="by" id="by" value = "gosil3"> 도어락OFF</a> <input type="hidden" name="y" id="y" value = "Y" /></li></ul> </form> <form id = "form6" action = "cgi-bin/index.cgi" method = "POST" class = "form"> <ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="bby" id="bby" value = "gosi4l"> 도어락ON</a> <input type="hidden" name="y" id="y" value = "y" /></li> </ul> </form> <div id="control3"> <div class="toolbar"> <h1> 경보기 </h1> <a class="button cancel" href="#">cancel</a> <form id = "form7" action = "cgi-bin/index.cgi" method = "POST" class = "form"> <ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="bu" id="bu" value = "gosil5"> 경보기OFF</a> <input type="hidden" name="u" id="u" value = "U" /></li></ul> </form> <form id = "form8" action = "cgi-bin/index.cgi" method = "POST" class = "form">

<ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="bbu" id="bbu" value = "gosil6"> 경보기ON</a> <input type="hidden" name="u" id="u" value = "u" /></li> </ul> </form> <div id="control4"> <div class="toolbar"> <h1> 가스밸브 </h1> <a class="button cancel" href="#">cancel</a> <form id = "form9" action = "cgi-bin/index.cgi" method = "POST" class = "form"> <ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="bi" id="bi" value = "gosil7"> 가스밸브OFF</a> <input type="hidden" name="i" id="i" value = "I" /></li></ul> </form> <form id = "form10" action = "cgi-bin/index.cgi" method = "POST" clss = "form"> <ul class="rounded"> <li><a style="margin:0 10px" href="#" class="submit" name="bbi" id="bbi" value = "gosil8"> 가스밸브ON</a> <input type="hidden" name="i" id="i" value = "i" /></li> </ul> </form> </body> </html> 5.3. Atmega128 코드 #include <mega128.h> #include <delay.h> #ifndef RXB8 #define RXB8 1 #endif #ifndef TXB8 #define TXB8 0 #endif #ifndef UPE #define UPE 2 #endif #ifndef DOR #define DOR 3 #endif #ifndef FE #define FE 4

#endif #ifndef UDRE #define UDRE 5 #endif #ifndef RXC #define RXC 7 #endif #define FRAMING_ERROR (1<<FE) #define PARITY_ERROR (1<<UPE) #define DATA_OVERRUN (1<<DOR) #define DATA_REGISTER_EMPTY (1<<UDRE) #define RX_COMPLETE (1<<RXC) // USART0 Receiver buffer #define RX_BUFFER_SIZE0 8 char rx_buffer0[rx_buffer_size0]; #if RX_BUFFER_SIZE0<256 unsigned char rx_wr_index0,rx_rd_index0,rx_counter0; #else unsigned int rx_wr_index0,rx_rd_index0,rx_counter0; #endif // This flag is set on USART0 Receiver buffer overflow bit rx_buffer_overflow0; // USART0 Receiver interrupt service routine interrupt [USART0_RXC] void usart0_rx_isr(void) char status,data; status=ucsr0a; data=udr0; if ((status & (FRAMING_ERROR PARITY_ERROR DATA_OVERRUN))==0) unsigned char key; key = PINC & 0xFF; if((data == 'Q')& (!((key & (1 << 7)) >> 7))) PORTA = 0B10000000; if(data == 'W'&!((key & (1 << 6)) >> 6))

PORTA = 0B01000000; if(data == 'E'&!((key & (1 << 5)) >> 5)) PORTA = 0B00100000; if(data == 'R'&!((key & (1 << 4)) >> 4)) PORTA = 0B00010000; if(data == 'T'&!((key & (1 << 3)) >> 3)) PORTA = 0B00001000; if(data == 'Y'&!((key & (1 << 2)) >> 2)) PORTA = 0B00000100; if(data == 'U'&!((key & (1 << 1)) >> 1)) PORTA = 0B00000010; if(data == 'I'&!((key & (1 << 0)) >> 0)) PORTA = 0B00000001; if((data == 'q')& (((key & (1 << 7)) >> 7))) PORTA = 0B10000000;

if(data == 'w'& ((key & (1 << 6)) >> 6)) PORTA = 0B01000000; if(data == 'e'& ((key & (1 << 5)) >> 5)) PORTA = 0B00100000; if(data == 'r'& ((key & (1 << 4)) >> 4)) PORTA = 0B00010000; if(data == 't'& ((key & (1 << 3)) >> 3)) PORTA = 0B00001000; if(data == 'y'& ((key & (1 << 2)) >> 2)) PORTA = 0B00000100; if(data == 'u'& ((key & (1 << 1)) >> 1)) PORTA = 0B00000010; if(data == 'i'& ((key & (1 << 0)) >> 0)) PORTA = 0B00000001; rx_buffer0[rx_wr_index0]=data; if (++rx_wr_index0 == RX_BUFFER_SIZE0) rx_wr_index0=0; if (++rx_counter0 == RX_BUFFER_SIZE0)

rx_counter0=0; rx_buffer_overflow0=1; ; ; #ifndef _DEBUG_TERMINAL_IO_ // Get a character from the USART0 Receiver buffer #define _ALTERNATE_GETCHAR_ #pragma used+ char getchar(void) char data; while (rx_counter0==0); data=rx_buffer0[rx_rd_index0]; if (++rx_rd_index0 == RX_BUFFER_SIZE0) rx_rd_index0=0; #asm("cli") --rx_counter0; #asm("sei") return data; #pragma used- #endif // USART0 Transmitter buffer #define TX_BUFFER_SIZE0 8 char tx_buffer0[tx_buffer_size0]; #if TX_BUFFER_SIZE0<256 unsigned char tx_wr_index0,tx_rd_index0,tx_counter0; #else unsigned int tx_wr_index0,tx_rd_index0,tx_counter0; #endif // USART0 Transmitter interrupt service routine interrupt [USART0_TXC] void usart0_tx_isr(void) if (tx_counter0) --tx_counter0; UDR0=tx_buffer0[tx_rd_index0]; if (++tx_rd_index0 == TX_BUFFER_SIZE0) tx_rd_index0=0; ; #ifndef _DEBUG_TERMINAL_IO_ // Write a character to the USART0 Transmitter buffer #define _ALTERNATE_PUTCHAR_ #pragma used+ void putchar(char c)

while (tx_counter0 == TX_BUFFER_SIZE0); #asm("cli") if (tx_counter0 ((UCSR0A & DATA_REGISTER_EMPTY)==0)) tx_buffer0[tx_wr_index0]=c; if (++tx_wr_index0 == TX_BUFFER_SIZE0) tx_wr_index0=0; ++tx_counter0; else UDR0=c; #asm("sei") #pragma used- #endif // Standard Input/Output functions #include <stdio.h> // Declare your global variables here void main(void) // Declare your local variables here unsigned char key; // Input/Output Ports initialization // Port A initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTA=0x00; DDRA=0x00; // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTB=0x00; DDRB=0x00; // Port C initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTC=0x00; DDRC=0x00; // Port D initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTD=0x00; DDRD=0x00; // Port E initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In

// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTE=0x00; DDRE=0x00; // Port F initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=In // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=T PORTF=0x00; DDRF=0x00; // Port G initialization // Func4=In Func3=In Func2=In Func1=In Func0=In // State4=T State3=T State2=T State1=T State0=T PORTG=0x00; DDRG=0x00; // Timer/Counter 0 initialization // Clock source: System Clock // Clock value: Timer 0 Stopped // Mode: Normal top=ffh // OC0 output: Disconnected ASSR=0x00; TCCR0=0x00; TCNT0=0x00; OCR0=0x00; // Timer/Counter 1 initialization // Clock source: System Clock // Clock value: Timer1 Stopped // Mode: Normal top=ffffh // OC1A output: Discon. // OC1B output: Discon. // OC1C output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer1 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off // Compare C Match Interrupt: Off TCCR1A=0x00; TCCR1B=0x00; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0x00; OCR1BH=0x00; OCR1BL=0x00; OCR1CH=0x00; OCR1CL=0x00;

// Timer/Counter 2 initialization // Clock source: System Clock // Clock value: Timer2 Stopped // Mode: Normal top=ffh // OC2 output: Disconnected TCCR2=0x00; TCNT2=0x00; OCR2=0x00; // Timer/Counter 3 initialization // Clock source: System Clock // Clock value: Timer3 Stopped // Mode: Normal top=ffffh // OC3A output: Discon. // OC3B output: Discon. // OC3C output: Discon. // Noise Canceler: Off // Input Capture on Falling Edge // Timer3 Overflow Interrupt: Off // Input Capture Interrupt: Off // Compare A Match Interrupt: Off // Compare B Match Interrupt: Off // Compare C Match Interrupt: Off TCCR3A=0x00; TCCR3B=0x00; TCNT3H=0x00; TCNT3L=0x00; ICR3H=0x00; ICR3L=0x00; OCR3AH=0x00; OCR3AL=0x00; OCR3BH=0x00; OCR3BL=0x00; OCR3CH=0x00; OCR3CL=0x00; // External Interrupt(s) initialization // INT0: Off // INT1: Off // INT2: Off // INT3: Off // INT4: Off // INT5: Off // INT6: Off // INT7: Off EICRA=0x00; EICRB=0x00; EIMSK=0x00; // Timer(s)/Counter(s) Interrupt(s) initialization TIMSK=0x00; ETIMSK=0x00;

// USART0 initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART0 Receiver: On // USART0 Transmitter: On // USART0 Mode: Asynchronous // USART0 Baud Rate: 9600 UCSR0A=0x00; UCSR0B=0xD8; UCSR0C=0x06; UBRR0H=0x00; UBRR0L=0x67; // Analog Comparator initialization // Analog Comparator: Off // Analog Comparator Input Capture by Timer/Counter 1: Off ACSR=0x80; SFIOR=0x00; // Global enable interrupts #asm("sei") DDRC = 0x00; DDRA = 0xFF; while(1) key = PINC & 0xFF; putchar(key); delay_ms(100);