유비쿼터스 컴퓨팅 및 실습 i pig final report. copyrightⓒsunriver leehyekang.blog.me 01....

23
Copyright SunRiver leehyekang.blog.m 유유유유유 유유유 유 유유 I Pig 2 08 유유유 08 유유유 08 유유유 08 유유유 09 유유유 Final Report

Upload: wendy-perkins

Post on 15-Jan-2016

227 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

유비쿼터스 컴퓨팅 및 실습

I Pig

2 조 08 정성혁 08 변상규 08 최종민 08 이희성 09 고현경

Final Report

Page 2: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

01. 과제명

Contents 목차

02. 과제개요

07. 업무분담

03. Arduino 적재 프로그램 코드

04. 데이터 관리 및 Viewer

05. 개발 산출물 메뉴얼

06. 개발 기간 및 일정

Koreatech Ubiquitous Computing Prac-tice 2

Page 3: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

과 제 명One

I Pig(Intelligent Pig)

Koreatech Ubiquitous Computing Prac-tice 3

Page 4: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

과제개요 (1)two

SNS

Intelligent 저금통

저금통

Sen-sor

Koreatech Ubiquitous Computing Prac-tice 4

Page 5: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

과제개요 (2)two

100

500

Koreatech Ubiquitous Computing Prac-tice 5

Page 6: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

프로그램 코드three

Koreatech Ubiquitous Computing Prac-tice 6

#include <SPI.h>#include <WiFi.h>#include <EEPROM.h>

#define CYCLE_MINUTE 1#define SUM_ADDRESS 10char ssid[] = "JJangLab";char key[] = "emsysjang";

char token[] = "1522334322-kEW8L7zXKiraIYNuhIIgSK7hm2wWe441yeOWJSA";char server_adr[] = "arduino-tweet.appspot.com";

unsigned long time = 0;unsigned long m = 60000;int status = WL_IDLE_STATUS;WiFiClient twtclient;String txt ="";int sumcoin=0;int coin=0; int flag=0;int pin1=0;int pin2=1;int pin3=2;int pin4=4;int pin5=7;int pin6=8;//tailmotoint pin9 =9;int pin10=10;

Page 7: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

프로그램 코드three

Koreatech Ubiquitous Computing Prac-tice 7

int incoin=0;int timecount=0;int beak=0, oship=0, obeak=0;int coinflag=0;void checktime();void insertcoin();void spinTail();void destroymode();void sparkEyes();

void setup(void){ Serial.begin(9600); pinMode(pin4,OUTPUT); pinMode(pin5,OUTPUT); pinMode(pin6,OUTPUT); pinMode(pin9,OUTPUT); pinMode(pin10,OUTPUT); digitalWrite(4,LOW); digitalWrite(7,LOW); analogWrite(9,10); analogWrite(10,10); while (!Serial) { } if (WiFi.status() == WL_NO_SHIELD) { Serial.println("WiFi shield not present"); while(true); }

Page 8: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

프로그램 코드three

Koreatech Ubiquitous Computing Prac-tice 8

void loop(){ checktime(); Serial.print(timecount); Serial.print(" "); Serial.print(incoin); Serial.println(""); if(timecount>=2000 && incoin==0){ destroymode(); } insertcoin();}void checktime(){ timecount++; delay(1);}void sparkEyes(){ int value = random(100,300); for(int i=0;i<4;i++){ analogWrite(9,255); delay(value); analogWrite(9,10); delay(value); analogWrite(10,255); delay(value); analogWrite(10,10); delay(value); delay(100); }}

Page 9: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

프로그램 코드three

Koreatech Ubiquitous Computing Prac-tice 9

void insertcoin(){ String temptxt; int read1 = analogRead(pin1); int read2 = analogRead(pin2); int read3 = analogRead(pin3); if(read1<200 && coinflag == 0){ coinflag = 1; Serial.println("50won input"); oship = 1; incoin = 1; time-count=0; coin +=50; spinTail(); } if(read2<200 && coinflag == 0){ coinflag = 1; Serial.println("100won input"); beak=1; incoin = 1; time-count=0; coin +=100; spinTail();} if(read3<200 && coinflag == 0){ coinflag = 1; Serial.println("500won input"); obeak = 1; incoin = 1; time-count=0; coin +=500; spinTail();} if(incoin==1 && timecount>=1000){ //sumcoin=EEPROM.read(SUM_ADDRESS); sumcoin+=coin; //EEPROM.write(SUM_ADDRESS,sumcoin); temptxt=""; temptxt+=coin; temptxt+="W Deposited! Total balance:"; temptxt+=sumcoin; temptxt+="W"; postTwt(temptxt); incoin=0; timecount=0; coin=0; flag=0; }}

Page 10: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

프로그램 코드three

Koreatech Ubiquitous Computing Prac-tice 10

void spinTail(){ sparkEyes(); digitalWrite(pin6,HIGH); // spin tail delay(2000); digitalWrite(pin6,LOW);// stop spin tail oship = 0; beak = 0; obeak = 0; timecount=0; Serial.println(incoin); coinflag = 0;}void destroymode(){ txt = "I'm hungry give me coin!!!!!"; if(flag == 0){ postTwt(txt); flag = 1; } int value = random(100,300); insertcoin(); if(!(incoin)){ digitalWrite(4,HIGH); delay(value); digitalWrite(4,LOW); delay(value); digitalWrite(7,HIGH); delay(value); digitalWrite(7,LOW); delay(value); }}

Page 11: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

프로그램 코드three

Koreatech Ubiquitous Computing Prac-tice 11

void printWifiStatus() { // print the SSID of the network you're attached to: Serial.print("SSID: "); Serial.println(WiFi.SSID()); // print your WiFi shield's IP address: IPAddress ip = WiFi.localIP(); Serial.print("IP Address: "); Serial.println(ip); // print the received signal strength: long rssi = WiFi.RSSI(); Serial.print("signal strength (RSSI):"); Serial.print(rssi); Serial.println(" dBm");}

void postTwt(String tweet) { Serial.print("tweet: "); Serial.println(tweet); if (twtclient.connect(server_adr, 80)) { Serial.println("connected"); twtclient.println("POST http://arduino-tweet.appspot.com/update HTTP/1.0"); twtclient.print("Content-Length: "); twtclient.println(tweet.length()+strlen(token)+14); twtclient.println(); twtclient.print("token="); twtclient.print(token); twtclient.print("&status="); twtclient.println(tweet); }

Page 12: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

프로그램 코드three

Koreatech Ubiquitous Computing Prac-tice 12

// if the server's disconnected, stop the twtclient: if (!twtclient.connected()) { Serial.println(); Serial.println("disconnecting from server."); twtclient.stop(); // do nothing forevermore: while(true); } Serial.println("twt finished");

}

Page 13: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

Viewer four

Koreatech UbiquitousKoreatech Ubiquitous Computing Prac-

tice 13

Page 14: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

Viewer four

Koreatech UbiquitousKoreatech Ubiquitous Computing Prac-

tice 14

Page 15: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

Viewer four

Koreatech UbiquitousKoreatech Ubiquitous Computing Prac-

tice 15

Page 16: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

개발 산출물 메뉴얼five

I’m hungry give me coin

I Pig설정 시간에 저금 하지 않음

Koreatech Ubiquitous Computing Prac-tice 16

Page 17: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

개발 산출물 메뉴얼five

동전 입력

100

500

진동 중단LED 켬

Koreatech Ubiquitous Computing Prac-tice 17

Page 18: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

개발 산출물 메뉴얼five

동전 입력

50

100

500

r

적외선 Sensor

Koreatech Ubiquitous Computing Prac-tice 18

50100

500

Page 19: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

개발 산출물 메뉴얼five

동전 입력 완료

100

500

동전 판별

Koreatech Ubiquitous Computing Prac-tice 19

Page 20: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

개발 산출물 메뉴얼five

동전 입력 완료

100\ depositedTotal money : 5200 \

I Pig

Koreatech Ubiquitous Computing Prac-tice 20

Page 21: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

개발기간 및 일정six

5 월 3 주차 5 월 4 주차 5 월 5

주차6 월 1

주차6 월 2

주차아이디어 및 주제선정 회의

하드웨어 개발

SNS 관련 API 연구

소프트웨어 개발

저금통과 아두이노의 연결

수정 및 보수

최종 발표 준비

Koreatech Ubiquitous Computing Prac-tice 21

Page 22: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

업무분담seven

상규기존 Coretex 마이크로프로세서를

네트워크 기반 SNS 를 이용하여 프로그래밍하였더니 신기하였다 .

현경아두이노가 오픈소스하드웨어라곤 했지만

안드로이드처럼 많은 소스를 찾기 힘들었다 . 아두이노를 공부해서 내가 만든 소스를

공유해야겠다 .

희성새로운 하드웨어를 접해보고 거기에

기능들을 여러가지 구현해보는게 굉장히 재미있었다 .

성혁아두이노를 처음 만져 봐서 재밌었고 앞으로

취미로 이용학 싶다는 생각을 하였습니다 . 처음 목표했던 기능을 모두 구현하지 못해많이 아쉬웠고 . 안식년 가시기 전에

좋은 수업 감사합니다 .~~~

종민기존의 마이크로프로세서를 이용하는

것보다 간단하게 하드웨어를 구성할 수 있다는 점이 흥미로웠다 .

Koreatech Ubiquitous Computing Prac-tice 22

Page 23: 유비쿼터스 컴퓨팅 및 실습 I Pig Final Report. CopyrightⓒSunRiver leehyekang.blog.me 01. 과제명 02. 과제개요 07. 업무분담 03. Arduino 적재 프로그램 코드

Copyright SunRiver leehyekang.blog.meⓒ

Q & AKoreatech Ubiquitous

Koreatech Ubiquitous Computing Prac-tice 23