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); }