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

Post on 15-Jan-2016

225 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

유비쿼터스 컴퓨팅 및 실습

I Pig

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

Final Report

Copyright SunRiver leehyekang.blog.meⓒ

01. 과제명

Contents 목차

02. 과제개요

07. 업무분담

03. Arduino 적재 프로그램 코드

04. 데이터 관리 및 Viewer

05. 개발 산출물 메뉴얼

06. 개발 기간 및 일정

Koreatech Ubiquitous Computing Prac-tice 2

Copyright SunRiver leehyekang.blog.meⓒ

과 제 명One

I Pig(Intelligent Pig)

Koreatech Ubiquitous Computing Prac-tice 3

Copyright SunRiver leehyekang.blog.meⓒ

과제개요 (1)two

SNS

Intelligent 저금통

저금통

Sen-sor

Koreatech Ubiquitous Computing Prac-tice 4

Copyright SunRiver leehyekang.blog.meⓒ

과제개요 (2)two

100

500

Koreatech Ubiquitous Computing Prac-tice 5

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;

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); }

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); }}

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; }}

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); }}

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); }

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");

}

Copyright SunRiver leehyekang.blog.meⓒ

Viewer four

Koreatech UbiquitousKoreatech Ubiquitous Computing Prac-

tice 13

Copyright SunRiver leehyekang.blog.meⓒ

Viewer four

Koreatech UbiquitousKoreatech Ubiquitous Computing Prac-

tice 14

Copyright SunRiver leehyekang.blog.meⓒ

Viewer four

Koreatech UbiquitousKoreatech Ubiquitous Computing Prac-

tice 15

Copyright SunRiver leehyekang.blog.meⓒ

개발 산출물 메뉴얼five

I’m hungry give me coin

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

Koreatech Ubiquitous Computing Prac-tice 16

Copyright SunRiver leehyekang.blog.meⓒ

개발 산출물 메뉴얼five

동전 입력

100

500

진동 중단LED 켬

Koreatech Ubiquitous Computing Prac-tice 17

Copyright SunRiver leehyekang.blog.meⓒ

개발 산출물 메뉴얼five

동전 입력

50

100

500

r

적외선 Sensor

Koreatech Ubiquitous Computing Prac-tice 18

50100

500

Copyright SunRiver leehyekang.blog.meⓒ

개발 산출물 메뉴얼five

동전 입력 완료

100

500

동전 판별

Koreatech Ubiquitous Computing Prac-tice 19

Copyright SunRiver leehyekang.blog.meⓒ

개발 산출물 메뉴얼five

동전 입력 완료

100\ depositedTotal money : 5200 \

I Pig

Koreatech Ubiquitous Computing Prac-tice 20

Copyright SunRiver leehyekang.blog.meⓒ

개발기간 및 일정six

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

주차6 월 1

주차6 월 2

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

하드웨어 개발

SNS 관련 API 연구

소프트웨어 개발

저금통과 아두이노의 연결

수정 및 보수

최종 발표 준비

Koreatech Ubiquitous Computing Prac-tice 21

Copyright SunRiver leehyekang.blog.meⓒ

업무분담seven

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

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

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

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

공유해야겠다 .

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

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

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

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

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

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

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

Koreatech Ubiquitous Computing Prac-tice 22

Copyright SunRiver leehyekang.blog.meⓒ

Q & AKoreatech Ubiquitous

Koreatech Ubiquitous Computing Prac-tice 23

top related