Amigos estou tentando fazer um rastreador solar com arduino e servo motores estou com dificuldade

Estou com dificuldade não sei muito de programação.

segue o codigo que peguei pegue mas, não funciona.

#define LedPin1 4  
#define LedPin2 5
    #include <Servo.h>
    Servo myservo;
    int pos = 0;  
    int inputesquerda = A1; 
    int inputdireita = A0;
    int esquerda = 0; 
    int direita = 0; 
    
    Servo myservo2;
    int pos2 = 0; 
    int inputcima = A2;
    int inputbaixo = A3;
    int ldr = A5
    int tldr = 0
    int cima  = 0; 
    int baixo = 0; 
    void setup()
    {
    myservo.attach(9);
    myservo2.attach(10); 
    }
    void loop()
    {
      pinMode(LedPin1, OUTPUT);  
pinMode(LedPin2, OUTPUT); 
    Left = analogRead(inputesquerda);
    Right = analogRead(inputdireita);
    tldr = analogRead(ldr);
    if (esquerda > (direita +20))
    {
    if (pos < 179)
    pos++;
    myservo.write(pos);
    }
 if(tldr>512){
   digitalWrite(LedPin1,HIGH);
   digitalWrite(LedPin2,HIGH);
 }
 else{
      digitalWrite(LedPin1,LOW); 
   digitalWrite(LedPin2,LOW);
 }
    if (direita > (esquerda +20))
    {
    if (pos > 1)
    pos -= 1;
    myservo.write(pos);
    }
    delay(10);
    cima = analogRead(inputcima);
    baixo = analogRead(inputbaixo);
    if (cima > (baixo +20))
    {
    if (pos2 < 179)
    pos2++;
    myservo2.write(pos2);
    }
    if (baixo > (cima +20))
    {
    if (pos2 > 1)
    pos2 -= 1;
    myservo2.write(pos2);
    }
    delay(10);
    }

Exibições: 139

Responder esta

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço