==========================================================================================
AVR
==========================================================================================
=AVR128
=PORTC만 숫자 데이터출력으로 사용하여 두자리 숫자 표현하기(PORTG는 7SEGMENT ON/OFF제어) => 잔상효과
1. PORTC 십의자리 숫자 셋팅
2. PORTG 십의자리 숫자 표시( 십의자리 ON / 일의자리 OFF )
3. PORTG 전체OFF
4. PORTC 일의자리 숫자 셋팅
5. PORTG 일의자리 숫자 표시( 십의자리 OFF / 일의자리 ON )
6. PORTG 전체OFF
7. (1번~6번)을 숫자가 눈으로 인식될만한 시간까지 FOR문으로 반복
=7SETMENT 두자리 숫자 COUNT UP
=> DELAY()는 상태에따라 추가/삭제/인자 값 적절히 변경해줌
-COMMON ANODE + ANODE
![](https://t1.daumcdn.net/cfile/tistory/2519304F552748B711)
=적절히 값 변경 후 동작 (COMMON ANODE + ANODE)
20150410.zip
==========================================================================================
네트워크
==========================================================================================
<C>
=TYPEDEF
typedef unsigned char Age;
Age Kim;
=구조체 : 긴 것 줄이기 / 의미 부여
-bit field structure : 메모리 용량 부족한 시절 사용 => 속도 느림 => 사용 안함
(네트워크 - ip버전에서 사용)
![](https://t1.daumcdn.net/cfile/tistory/2478AF3955278B432B)
#include <stdio.h>
typedef struct _smart { unsigned char A:4; unsigned char B:4; }smart;
int main() { smart obj1; printf("obj1 size : [%d]",sizeof(obj1)); return 0; } |
![](https://t1.daumcdn.net/cfile/tistory/210CBE3955278B4621)
-
![](https://t1.daumcdn.net/cfile/tistory/266A9F3955278B4738)
#include <stdio.h>
typedef struct _smart { unsigned char A:4; unsigned char B:4; }smart;
int main() { smart obj1; obj1.A = 10; obj1.B = 16; printf("obj1 size : [%d]\n",sizeof(obj1)); printf("obj1.A : [%d]\n", obj1.A); printf("obj1.B : [%d]\n", obj1.B); return 0; } |
![](https://t1.daumcdn.net/cfile/tistory/232FBE3955278B4A0A)
-구조체 배열
#include <stdio.h>
struct point { int xpos; int ypos; };
int main() { struct point arr[3]; int i;
for(i=0; i<3; ++i) { printf("점의 좌표 입력: "); scanf("%d %d", &arr[i].xpos, &arr[i].ypos); }
for(i=0; i<3; ++i) printf("[%d, %d] ", arr[i].xpos, arr[i].ypos);
return 0; } |
![](https://t1.daumcdn.net/cfile/tistory/2450AD3755278B4D0A)
-구조체 배열 초기화
#include <stdio.h>
struct person { char name[20]; char phoneNum[20]; int age; };
int main() { struct person arr[3] = { {"이승기", "010-1212-0001", 21}, // 첫 번째 요소 초기화 {"정지영", "010-1313-0002", 22}, // 두 번째 요소 초기화 {"한지수", "010-1717-0003", 19} // 세 번째 요소 초기화 };
int i;
for(i=0; i<3; ++i) printf("%s %s %d \n", arr[i].name, arr[i].phoneNum, arr[i].age);
return 0; } |
![](https://t1.daumcdn.net/cfile/tistory/2420803755278B502A)
-구조체 변수와 포인터
#include <stdio.h>
typedef struct _smart { int iNum; }smart;
int main() { smart A; smart * P; P = &A; // cf - 배열은 & 없어도 됨
A.iNum = 100; // WRITE - 1
printf("A.iNum : [%d] \n",A.iNum); printf("(*P).iNum : [%d] \n",(*P).iNum); // READ
(*P).iNum = 200; // WRITE - 2 printf("A.iNum : [%d] \n",A.iNum); // A값 변경 확인
P->iNum = 300; // WRITE - 3 printf("A.iNum : [%d] \n",A.iNum); // A값 변경 확인 printf("P->iNum : [%d] \n",P->iNum); // A값 변경 확인
return 0; } |
![](https://t1.daumcdn.net/cfile/tistory/2376D441552879B411)
![](https://t1.daumcdn.net/cfile/tistory/2449473755278B5410)
-예제 (P464)
#include <stdio.h>
struct point { int xpos; int ypos; }; int main() { struct point pos1 = {1,2}; struct point pos2 = {100, 200}; struct point * pptr = &pos1;
(*pptr).xpos += 4; (*pptr).ypos += 5; printf("[%d, %d] \n", pptr->xpos, pptr->ypos);
pptr = &pos2; (*pptr).xpos += 1; (*pptr).ypos += 2; printf("[%d, %d] \n", pptr->xpos, pptr->ypos);
return 0; } |
![](https://t1.daumcdn.net/cfile/tistory/2447BA3A55278B561F)
=포인터변수를 구조체 멤버로 선언(P465)
#include <stdio.h>
struct point { int xpos; int ypos; };
struct circle { double radius; struct point * center; };
int main() { struct point cen = {2, 7}; double rad = 5.5;
struct circle ring = {rad, &cen}; printf("원의 반지름: %g \n", ring.radius); printf("원의 중심 [%d, %d] \n", (ring.center)->xpos, (ring.center)->ypos); return 0; } |
![](https://t1.daumcdn.net/cfile/tistory/2333FF3A55278B5926)
=예제(P467)
#include <stdio.h>
struct point { int xpos; int ypos; struct point * ptr; };
int main() { struct point pos1 = {1, 1}; struct point pos2 = {2, 2}; struct point pos3 = {3, 3};
pos1.ptr = &pos2; //pos1과 pos2를 연결 pos2.ptr = &pos3; //pos2과 pos3를 연결 pos3.ptr = &pos1; //pos3과 pos1를 연결
printf("점의 연결관계... \n"); printf("[%d, %d]와(과) [%d, %d] 연결 \n", pos1.xpos, pos1.ypos, pos1.ptr->xpos, pos1.ptr->ypos);
printf("[%d, %d]와(과) [%d, %d] 연결 \n", pos2.xpos, pos2.ypos, pos2.ptr->xpos, pos2.ptr->ypos);
printf("[%d, %d]와(과) [%d, %d] 연결 \n", pos3.xpos, pos3.ypos, pos3.ptr->xpos, pos3.ptr->ypos);
return 0; } |
![](https://t1.daumcdn.net/cfile/tistory/2368263A55278B5B0D)
![](https://t1.daumcdn.net/cfile/tistory/2537643A55278B6123)
=구조체 변수의 주소 값과 첫 번째 멤버의 주소 값
=> 동일 (P468)
#include <stdio.h> struct point { int xpos; int ypos; };
struct person { char name[20]; char phoneNum[20]; int age; };
int main() { struct point pos = {10, 20}; struct person man = {"이승기", "010-1212-0001", 21};
printf("%p %p \n", &pos, &pos.xpos); printf("%p %p \n", &man, man.name);
return 0; } |
![](https://t1.daumcdn.net/cfile/tistory/221FE73855278B6432)
<네트워크>
=Internet : Inter Network
1. 방위 고등 연구 계획국(DARPA , Defense Advanced ResearchProjects Agency) - 국가기관 (투자자)
2. AT&T -회사
Bell 연구소(Bell사) => Unix 기반 NETWORK 테스트
3. 버클리대학 -대학
=> 1 / 2 / 3 모여 규약(protocol - 악수..) 문서로( -> 국제규약(IEEE / ISO)) 작성 => TEST(ALPHA NET)
=> TEST 망 => ALPHA NET => 다른기관 참가 => 망이 확대/복잡 => INTERnational NETwork
- IP ( Internet Protocal )