gysguygd

rctEVKq.png



#include 

Servo myservo;  // create servo object to control a servo
int pos = 90;

void setup()
{
  pinMode(13, OUTPUT);
  myservo.attach(9);
  Serial.begin(9600);
  Serial.println("começou");
  
}

void loop()
{
  
  int valorLDR1;
  int valorLDR2;
  myservo.write(pos);
  digitalWrite(13, HIGH);
  delay(500); // Wait for 1000 millisecond(s)
  digitalWrite(13, LOW);
  myservo.write(pos);
  delay(500); // Wait for 1000 millisecond(s)
  valorLDR1 = analogRead(A0);
  Serial.println(valorLDR1);
  valorLDR2 = analogRead(A1);
  Serial.println(valorLDR2);
  if ((valorLDR1 > valorLDR2) && (pos < 180)) pos++;
  if ((valorLDR1 < valorLDR2) && (pos > 0)) pos--;
  
  
}


sdsadsadsda


Atividades recentes