face tracking 아두이노 코드
전공/Opencv#include <Servo.h>
Servo myservo1;
Servo myservo2;
int pos1 =90;
int pos2 =90;
void setup(){
Serial.begin(9600);
myservo1.attach(9);
myservo2.attach(10);
}
void loop(){
if(Serial.available());
{
int a=(int)Serial.read();
if(a=='1')
{
pos1 = pos1 - 1;
pos2 = pos2 + 1;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='4')
{
pos1 = pos1;
pos2 = pos2 + 1;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='7')
{
pos1 = pos1 + 1;
pos2 = pos2 + 1;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='2')
{
pos1 = pos1 - 1;
pos2 = pos2;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='5')
{
pos1 = pos1;
pos2 = pos2;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='8')
{
pos1 = pos1 + 1;
pos2 = pos2;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='3')
{
pos1 = pos1 - 1 ;
pos2 = pos2 - 0.8;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='6')
{
pos1 = pos1;
pos2 = pos2 - 0.8;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='9')
{
pos1 = pos1 + 1;
pos2 = pos2 - 0.8;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
}
}
Servo myservo1;
Servo myservo2;
int pos1 =90;
int pos2 =90;
void setup(){
Serial.begin(9600);
myservo1.attach(9);
myservo2.attach(10);
}
void loop(){
if(Serial.available());
{
int a=(int)Serial.read();
if(a=='1')
{
pos1 = pos1 - 1;
pos2 = pos2 + 1;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='4')
{
pos1 = pos1;
pos2 = pos2 + 1;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='7')
{
pos1 = pos1 + 1;
pos2 = pos2 + 1;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='2')
{
pos1 = pos1 - 1;
pos2 = pos2;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='5')
{
pos1 = pos1;
pos2 = pos2;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='8')
{
pos1 = pos1 + 1;
pos2 = pos2;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='3')
{
pos1 = pos1 - 1 ;
pos2 = pos2 - 0.8;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='6')
{
pos1 = pos1;
pos2 = pos2 - 0.8;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
else if(a=='9')
{
pos1 = pos1 + 1;
pos2 = pos2 - 0.8;
myservo1.write(pos1);
myservo2.write(pos2);
Serial.println(a);
delay(10);
}
}
}
'전공 > Opencv' 카테고리의 다른 글
face tracking C 코드 (3) | 2019.10.31 |
---|---|
Face-tracking Robot 졸업작품 (18) | 2018.01.29 |
저장된 사진 띄우기 (0) | 2017.07.24 |
ubuntu 16.04 opencv 3.2.0 설치 (2) | 2017.07.21 |
노트북 카메라 연동 얼굴 인식 (0) | 2017.07.14 |