Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
mathparrachorenanbreis
Published © MIT

Camera Follower - 180 degrees

Computer vision to recognize your face and follow you through the room!

AdvancedProtip200
Camera Follower - 180 degrees

Things used in this project

Story

Read more

Code

Movement system

C/C++
#include <Servo.h>

#define SERVO 10
#define SERVOY 9
Servo S;
Servo SY;

int pos = 90;
int counter = 90;

int posY = 70;
int counterY = 70;

char comando;

void setup() {
  Serial.begin(9600);
 
 S.attach(SERVO);
 S.write(90);

 SY.attach(SERVOY);
 SY.write(70);
 
}

void loop() {

  if (!Serial.available()) comando = 'Z';
  
  while (Serial.available()) {
    comando = Serial.read();
  }


  if (comando == 'A') {
   direita();
   counter = pos;
  }

 else if (comando == 'B') {
  esquerda();
  counter = pos;
  }

  else if (comando == 'C') {
   cima();
   counterY = posY;
  }

 else if (comando == 'D') {
  baixo();
  counterY = posY;
  }
}
 


void esquerda() {
 for(pos; pos<counter+1; pos++)
 {  
    S.write(pos);
    delay(50);
 }
 delay(20);
}


void direita() {
  for(pos; pos>=counter-1; pos--){
    S.write(pos);
    delay(50);
 }
 delay(20);
}


void cima() {
 for(posY; posY<counterY+1; posY++)
 {  
    SY.write(posY);
    delay(50);
 }
 delay(20);
}


void baixo() {
  for(posY; posY>=counterY-1; posY--){
    SY.write(posY);
    delay(50);
 }
 delay(20);
}

Credits

mathparracho

mathparracho

3 projects • 0 followers
renanbreis

renanbreis

4 projects • 0 followers

Comments