# Servo not respecting code

**URL:** <https://forum.arduino.cc/t/servo-not-respecting-code/1128506>\
**Category:** General Guidance\
**Created:** [May 18, 2023, 7:24pm UTC](https://forum.arduino.cc/t/servo-not-respecting-code/1128506 "2023-05-18T19:24:14Z")\
**Posts on this page:** 1\
**Showing post:** 33

<div class="post-metadata">

**Author:** ![Grumpy\_Mike](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/grumpy_mike/32/213521_2.png) [@Grumpy\_Mike](https://forum.arduino.cc/u/Grumpy_Mike)\
**Post date:** [May 19, 2023, 9:06pm UTC](https://forum.arduino.cc/t/servo-not-respecting-code/1128506/33 "2023-05-19T21:06:22Z")

</div>

> [@CristyRO9](#):
>
> is it because my pins are not soldered

You were told in no uncertian terms in your other thread:-

> [@Arudino doesn't work after disconnecting the USB from the pc even with the code uploaded and the PSU connected](https://forum.arduino.cc/t/arudino-doesnt-work-after-disconnecting-the-usb-from-the-pc-even-with-the-code-uploaded-and-the-psu-connected/1128306/21):
>
> Solder the pins to the Nano and report back what happens when you try the sketch and the circuit

That the pins **NEED** to be soldered to your board. With out doing this you are just wasting **EVERY BODIES** time.

> [@CristyRO9](#):
>
> ` if(counter = 1)`

Should be  
` if(counter == 1)`  
Along with all your other 'if' tests.

> [@CristyRO9](#):
>
> the counter is equal to 1,is it a mistake from the code

The code is doing exactly what you told it to do.

> [@CristyRO9](#):
>
> ```arduino
> if (buttonState != lastButtonState)
> {
> if (buttonState == HIGH)
> {
> counter++;
> Serial.print("Number of button pushes: ");
> Serial.println(counter);
> }
> 
> ```

Before the count variable is ever printed it is incremented. So if you start with count = 0 then it will be equal to 1 before it is printed for the first time.  
Quick fix make count = -1 when you declare it.

---

_[View the full topic](https://forum.arduino.cc/t/servo-not-respecting-code/1128506)._
