# Help a Newbie Please?!?!

**URL:** <https://forum.arduino.cc/t/help-a-newbie-please/1368706>\
**Category:** Programming\
**Created:** [March 29, 2025, 7:33pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706 "2025-03-29T19:33:14Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![navyslideby](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/navyslideby/32/1127280_2.png) [@navyslideby](https://forum.arduino.cc/u/navyslideby)\
**Post date:** [March 29, 2025, 7:33pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/1 "2025-03-29T19:33:14Z")

</div>

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

```arduino
#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;
  }
 }

}

```

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [March 29, 2025, 7:35pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/2 "2025-03-29T19:35:35Z")

</div>

Welcome to the forum

```cpp
Servo largeservo;

```

What is the name of the servo ?

```cpp
        largeServo.write(90);

```

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

---

<div class="post-metadata">

**Author:** ![navyslideby](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/navyslideby/32/1127280_2.png) [@navyslideby](https://forum.arduino.cc/u/navyslideby)\
**Post date:** [March 29, 2025, 7:37pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/3 "2025-03-29T19:37:43Z")

</div>

I thought me typing in

```arduino
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???

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [March 29, 2025, 7:39pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/4 "2025-03-29T19:39:34Z")

</div>

You have named the servo largeservo

You are writing to a servo named largeServo

Spot the difference in the names

---

<div class="post-metadata">

**Author:** ![navyslideby](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/navyslideby/32/1127280_2.png) [@navyslideby](https://forum.arduino.cc/u/navyslideby)\
**Post date:** [March 29, 2025, 7:40pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/5 "2025-03-29T19:40:38Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![navyslideby](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/navyslideby/32/1127280_2.png) [@navyslideby](https://forum.arduino.cc/u/navyslideby)\
**Post date:** [March 29, 2025, 7:41pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/6 "2025-03-29T19:41:15Z")

</div>

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

I did in 1 instance miss the capital on the S

Thank you!!!!

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [March 29, 2025, 7:44pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/8 "2025-03-29T19:44:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![navyslideby](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/navyslideby/32/1127280_2.png) [@navyslideby](https://forum.arduino.cc/u/navyslideby)\
**Post date:** [March 29, 2025, 7:44pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/9 "2025-03-29T19:44:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PaulRB](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/paulrb/32/216330_2.png) [@PaulRB](https://forum.arduino.cc/u/PaulRB)\
**Post date:** [March 29, 2025, 7:44pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/10 "2025-03-29T19:44:53Z")

</div>

> [@navyslideby](#):
>
> `motionStatus + digitalRead(pirPin);`

Another typo?

---

<div class="post-metadata">

**Author:** ![navyslideby](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/navyslideby/32/1127280_2.png) [@navyslideby](https://forum.arduino.cc/u/navyslideby)\
**Post date:** [March 29, 2025, 7:46pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/11 "2025-03-29T19:46:18Z")

</div>

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!!!

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [March 29, 2025, 7:47pm UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/12 "2025-03-29T19:47:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sonofcy](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sonofcy/32/1283617_2.png) [@sonofcy](https://forum.arduino.cc/u/sonofcy)\
**Post date:** [March 30, 2025, 12:26am UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/13 "2025-03-30T00:26:09Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 26, 2025, 12:27am UTC](https://forum.arduino.cc/t/help-a-newbie-please/1368706/14 "2025-09-26T00:27:00Z")

</div>

Closed on September 26, 2025, 12:27am UTC

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