So i am trying to make the servo follow my face which will end up my camera following my face
But the servo isnt doing anything please look at this (Also im only using Horizontal because I would like to start off with that first)
Question : how do i make it so it can move, what am i doing wrong?
Python code : https://pastebin.com/V6SegsQj
Arduino code :
#include<Servo.h>
Servo servoHor; //Horizontal Servo
int x;
int prevX;
void setup()
{
Serial.begin(9600);
servoHor.attach(6); //Attach Horizontal Servo to Pin 6
servoHor.write(90);
}
void Pos()
{
if(prevX != x)
{
int servoX = map(x, 600, 0, 70, 179);
servoX = min(servoX, 179);
servoX = max(servoX, 70);
servoHor.write(servoX);
}
}
void loop()
{
if(Serial.available() > 0)
{
if(Serial.read() == 'X')
{
x = Serial.parseInt();
}
while(Serial.available() > 0)
{
Serial.read();
}
}
}
Pos()is never being called. It can't ever do anything. – Majenko Oct 06 '20 at 12:09