Girassol com servo e atmega328

//girassol com servo e atmega328
//fonte:
//pedroluand@gmail.com
//versao:1.0
//19-11-2018

#include "Servo.h" //biblioteca controle de servo

Servo myservo;

int pos = 0;
int inputPhotoLeft = 1;
int inputPhotoRight = 0;

int Left = 0;
int Right = 0;

void setup()  {
Serial.begin(9600);
myservo.attach(9);
}

void loop()  {
Left = analogRead(inputPhotoLeft);
Right = analogRead(inputPhotoRight);
Serial.println(Left);
Serial.println(Right);

if (Left > (Right +20))  {
if (pos < 179)
pos++;
myservo.write(pos);
}

if (Right > (Left +20))  {
if (pos > 1)
pos -= 1;
myservo.write(pos);
}

delay(10);
}

Comentários

Postagens mais visitadas deste blog

Amplificador de 6W para módulos PLL FM, usando transistores C1970 e C1971 - Versão final 04-04-2022

Amplificador de RF 350mW com BD135 para modulos pll

Antena dipolo para transmissores FM