SERVO not working, with Nano

Hello. My first time using Arduino, though not the first time using a microcontroller.
Trying to run a servo from 0 to 180degrees and back; very standard. . Here are the specifics:

Arduino: 1.8.19 (Windows 10), Board: "Arduino Nano, ATmega328P (Old Bootloader)"
Code is from examples, copied below.
Using an external battery for power (an energizer 6 volts lantern battery). A single servo (DSSERVO)
Servo is connected to D9, and the positive and negative battery terminals.
Negative battery terminal also connected to the board. The nano board is called NANO LAFVIN. It sits on top of a socket board that has terminals for connecting wires. Connected to a USB port.
The servo does not move when the code is uploaded. On rare occasions, when I touch the board, there is a small movement, but it is not repeatable. I have tried to power the Servo using power from the Board and external. I have used 2 different laptops, each one with 2 USB ports, 2 different USB cables, 2 different Servos and 2 different nano boards. Result is the same. The code compiles, but I get the error:

avrdude: stk500_recv(): programmer is not responding
Same error for all boards, and all the other pieces of hardware and laptops.

Please let me know what I am missing or I can try. Here is a photo

AND here is the code:

/* Sweep
by BARRAGAN http://barraganstudio.com
This example code is in the public domain.

modified 8 Nov 2013
by Scott Fitzgerald
https://www.arduino.cc/en/Tutorial/LibraryExamples/Sweep
*/

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
}

So you haven't actually managed to upload the code yet?

Do you have the correct board selected?

Do you have the correct port selected?

Posting schematics always helps us givining advice instead of guesses or lots of qestions.

Yes, I have chosen the correct Board (Nano) and the right port (COM3) on one laptop and COM4 on the other. And yes, you are right, the code does not actually load, it tries and then times out.

Hi,
Can you please show a picture of the other side of the PCB you have the Nano plugged into?

Did you solder it yourself?

Do you have a DMM?

Have you tried loading code into the Nano with it unplugged from the PCB?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Hello
You will stay not alone. Take a view:

Have a nice day and enjoy programming in C++ and learning.
Errors and omissions excepted.
Дайте миру шанс!

Here is a rough schematic.

Hi Tom,
Here are photos of the Adapter board, front and back. There was no soldering, the Nano Board just plugs into the socket and there are tiny wiring terminals on both sides. The White wire from the Servo is connected to D9.
DMM as in voltmeter? no.
How do I load the code into the Nano board without the USB connection?
Thank you.

And here is the back of the adapter board.

Hi,

I said;

Keep the USB connection, just don't have the Nano plugged into the PCB.

Tom... :smiley: :+1: :coffee: :australia:

It is working now. very strange. I changed the processor selection from what the instructions had indicated to another one....from ATmega328P (Old Bootloader) to just ATmega328P... and it started to work. Sure enough, I then changed back to the Bootloader and it keeps working. Ghosts in the Nano.
I am scratching my head as to why did it not work before, and why is it working now....
In fact its working without the battery too (power from the small Nano board to the servo).

Thank you for all your help.

mark this thread as "SOLVED"

That's asking for trouble, and is discouraged.

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