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
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
}
}
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 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.
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).