Help a Newbie Please?!?!

I am trying to write this code so that i can get a servo to actuate something for me on a delay. I am almost entirely following a video on Youtube created by Rachel De Barros ( Motion-activated Servo Motors with Arduino and PIR Sensor) but ive run into an issue. I included the Servo Library and im trying to "Declare" my servo as largeservo as you can see below in my copy pasted code (dont know a better way to do this) however i keep getting an error "Compilation error: 'largeServo' was not declared in this scope. I thought this was a global declaration and i have even tried to put that declaration into every scope but it makes no difference. also dont know if it matters but when i include the servo library my <Servo.h> does not change colors like other peoples do and neither does my declaration line Servo largeServo;
Can anyone help me understand whats wrong please!?!?
Thank you in advance

#include <Servo.h>

Servo largeServo;

int pirPin = 12;
int servoPin = 9;

int motionStatus = 0;
int pirState = 0;



void setup() {
  Serial.begin(9600);
  pinMode (pirPin, INPUT);
largeServo.attach(servoPin);
largeServo.write(0);

  delay(1000);
}

void loop() {
motionStatus + digitalRead(pirPin);

if (motionStatus == HIGH) {


largeServo.write(90);

delay(3000);

largeServo.write(0);

if (pirState == LOW) {
  Serial.println("Motion Detected");
  pirState = HIGH;
  }
}

 else {

  if(pirState == HIGH) {
  Serial.println("Motion Ended");
  pirState = LOW;
  }
 }

}

Welcome to the forum

Servo largeservo;

What is the name of the servo ?

        largeServo.write(90);

What is the name of the servo that you are writing to ?

I thought me typing in

Servo largeServo;

Was me naming the servo for the declaration and i could then use largeServo.write or largeServo.attach after that.... is this not the case???

You have named the servo largeservo

You are writing to a servo named largeServo

Spot the difference in the names

That was simply a typo in this forum. all names in the software are largeServo

ahhh crap.... you are right lol im sorry..

I did in 1 instance miss the capital on the S

Thank you!!!!

I am glad that you spotted it

In future use Edit/Copy for Forum to copy code from the IDE rather that typing it into the forum

Devil is in the details with this stuff for sure. And i will keep that in mind thank you!

Another typo?

dang good catch, thank you. I need to take my time more and go back through and make sure i read everything i just typed thoroughly!!!

Sometimes the error messages can be a little obtuse but not in this case

This is a case where you put the cursor on the thing you want to investigate, like largeServo on line 3, and then press Cmd-E for Mac or whatever for Windows. If that doesn't clue you in, I don't know what will.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.