2014-09-03 15:04:22



| NO | 부품명 | 수량 | 상세정보 |
| 1 | 아두이노 보드 | 1 | UNO, Mega2560, MegaADK |
| 2 | 브레드 보드 | 1 | |
| 3 | 서보 모터 | 2 | |
| 4 | 웹캠 | 1 | |
| 5 | 케이블 | 6~10 |
| 부품명 | 아두이노 보드 | 브레드 보드 | 서보 모터 2개 | 웹캠 | 케이블 |
| 부품 사진 | ![]() |
![]() |
![]() |
![]() |
![]() |




import processing.serial.*; // Combining GSVideo capture with the OpenCV library for face detection // http://ubaa.net/shared/processing/opencv/ import hypermedia.video.*; import java.awt.Rectangle; import codeanticode.gsvideo.*; OpenCV opencv; GSCapture cam; //서보모터를 구분하는 값 char verticalSignal = 1; char horizonSignal = 0;
//시리얼을 초기화하고 초기각도를 90도로 지정 Serial myport; int x = 90; int y = 90; void setup(){
//창의 크기와 캠 영상크기를 (640x480)로 지정 size(640, 480); cam = new GSCapture(this, 640, 480); cam.start(); opencv = new OpenCV(this); opencv.allocate(640,480);
//시리얼 통신 초기화 myport = new Serial(this,Serial.list()[0],9600); } void captureEvent(GSCapture c) { c.read(); } public void stop() { opencv.stop(); super.stop(); } void draw(){ opencv.copy(cam); opencv.convert(GRAY); image(cam, 0, 0); //창크기 640x480을 180도로 맞추기 위해 나누기3과 나누기2를 각각 해준다 print("mouseX = "); println(mouseX/3); print("mouseY = "); println(mouseY/2); x = mouseX/3; y = mouseY/2; //시리얼통신을 통해 각도값 전송 myport.write(horizonSignal); myport.write(x); myport.write(verticalSignal); myport.write(y); delay(1); }
//창크기 640x480을 180도로 맞추기 위해 나누기3과 나누기2를 각각 해준다
print("mouseX = ");
println(mouseX/3);
print("mouseY = ");
println(mouseY/2);
x = mouseX/3;
y = mouseY/2;
myport.write(horizonSignal); myport.write(x); myport.write(verticalSignal); myport.write(y); delay(1);
#include <Servo.h> // 서보 라이브러리 사용
int x ;
int y ;
char verticalSignal=1, horizonSignal=0;
char serialChar=0;
Servo servoA; // 서보 선언
Servo servoB; // 서보 선언
void setup(){
Serial.begin(9600); //시리얼 통신 시작
servoA.attach(10); // 서보 신호핀 10번
servoB.attach(9); // 서보 신호핀 10번
servoA.write(90);
servoB.write(90);
}
void loop(){
while(Serial.available() <=0);
serialChar = Serial.read();
if(serialChar == horizonSignal){
while(Serial.available() <=0);
x = Serial.read();
servoA.write(x);
}
else if(serialChar == verticalSignal){
while(Serial.available() <= 0);
y=Serial.read();
servoB.write(y);
}
}
수박쨈
아두이노, 서보모터, 프로세싱, 웹캠, OpenCV