'ModuModus 전시'에 해당되는 글 10건
Gym battle
ModuModus 전시 2007. 11. 9. 14:55![사용자 삽입 이미지](https://t1.daumcdn.net/tistoryfile/fs2/14_18_10_2_blog71341_attach_0_4.png?original)
작업 이미지
![사용자 삽입 이미지](https://t1.daumcdn.net/tistoryfile/fs3/14_18_10_2_blog71341_attach_0_1.png?original)
9V 전지가 달려있는 각각의 미니 아두이노 보드는 2개의 틸트 센서에서 신호를 받아 그 신호를 다른 쪽의 Xbee 아두이노 보드에 보내게 된다.
각각의 device에서 송신하는 코드는 다음과 같다.
--준비중![사용자 삽입 이미지](https://t1.daumcdn.net/tistoryfile/fs3/13_18_10_2_blog71341_attach_0_0.png?original)
![사용자 삽입 이미지](https://t1.daumcdn.net/tistoryfile/fs3/13_18_10_2_blog71341_attach_0_1.png?original)
![사용자 삽입 이미지](https://t1.daumcdn.net/tistoryfile/fs3/13_18_10_2_blog71341_attach_0_2.png?original)
#define HOOLA 3
#define ROPE 1
#define DUMBBEL 2
int incomingByte = 0; // for incoming serial data
int hoolaCount = 0;
int ropeCount = 0;
int dumbbelCount = 0;
int totalCount = 0;
int winningCounters = 0;
int winningLoop = 0;
int val = 0;
int oldWinner = 0;
int winner = 0;
int i = 0;
void restartCounters() {
hoolaCount = 0;
ropeCount = 0;
dumbbelCount = 0;
totalCount = 0;
}
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
restartCounters();
}
void loop() {
// send data only when you receive data:
if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
totalCount++;
switch(incomingByte){
case '3':
hoolaCount = hoolaCount + 1;
break;
// break is optional
case '1':
ropeCount = ropeCount + 1;
break;
case '2':
dumbbelCount = dumbbelCount + 1;
break;
}
}
if (totalCount >=20) {
if(hoolaCount >= ropeCount && hoolaCount >= dumbbelCount){
winner = HOOLA;
}
else if(ropeCount >= hoolaCount && ropeCount >= dumbbelCount){
winner = ROPE;
}
else if(dumbbelCount >= ropeCount && dumbbelCount >= hoolaCount){
winner = DUMBBEL;
}
switch (winner) {
case HOOLA:
Serial.print("VPF");
Serial.print(32, BYTE);
Serial.print("3.mp3");
break;
case ROPE:
Serial.print("VPF");
Serial.print(32, BYTE);
Serial.print("1.mp3");
break;
case DUMBBEL:
Serial.print ("VPF");
Serial.print(32, BYTE);
Serial.print("2.mp3");
break;
default:
Serial.print("VST");
}
Serial.print(13, BYTE);
winningCounters = 0;
Serial.flush();
delay(5000);
}
delay(1000);
restartCounters();
winningCounters++;
}
}