Servo and LDR

Hi! I'm trying to make one servo to follow the light with two LDR's. I've been searching how to do it since I'm new with arduino and programming. I've done the code bellow with my knowledge but the servo don't move and I can't understand what am I doing wrong. Can anyone help me ? Thanks.

#include <Servo.h>
int pinoum = A0;
int pinodois = A1;
int valum = 0;
int valdois = 0;
Servo servo;
#define saida 2
float pos = 90;

void setup() {
  pinMode (saida, OUTPUT);
  Serial.begin(19200);
}

void loop() {
  valum = analogRead(pinoum);
  valdois = analogRead(pinodois);
  float volum = valum*(5.0/1023.0);
  float voldois = valdois*(5.0/1023.0);
  Serial.println(volum);
  Serial.println(voldois);
  
  if (volum>voldois){
    pos=pos+1;
    pos=constrain(pos,0,179);
    servo.write(pos);
    delay(1000);
  }
  else{
    if(valum<valdois){
      pos=pos-1;
      pos=constrain(pos,0,179);
      servo.write(pos);
      delay(1000);
    }
  }
  
  Serial.println(pos);
}

What values do you get from

Serial.println(volum);
  Serial.println(voldois);

Look at the servo example, I can't see anywhere in your code that you tell the servo library what pin the servo is on.

Thanks, now it's moving :slight_smile:

I get values between 0 and 5