Hello,
I am a newb and trying to get an Arduino Nano to work for a specific project running 3 servo motor boards. I am following the directions and code of someone who has made it before, but I am having trouble getting the Nano to respond. Specifically, I can compile the basic code, and send it to the Nano, but I am expecting it to print "Ready for command" in the serial monitor, but despite the fact that the code looks correct and it appears to connect and upload without issue, I am not getting the expected "Ready for command" output and I am not able to send input to the Nano. I have looked over the old forum posts and tried the suggestions including resets of the nano, changing ports, trying a different bootloader and reviewing the verbose feedback. I can't see where it is going wrong. I will offer the code and the verbose feedback below. Any thoughts on the issue is greatly appreciated.
Verbose feedback:
"FQBN: arduino:avr:nano
Using board 'nano' from platform in folder: C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Using core 'arduino' from platform in folder: C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6
Detecting libraries used...
C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\sketch\Clockception_Calibrate_Positions.ino.cpp -o nul
Alternatives for Wire.h: [Wire@1.0]
ResolveLibrary(Wire.h)
-> candidates: [Wire@1.0]
C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\sketch\Clockception_Calibrate_Positions.ino.cpp -o nul
Alternatives for Adafruit_PWMServoDriver.h: [Adafruit PWM Servo Driver Library@3.0.2]
ResolveLibrary(Adafruit_PWMServoDriver.h)
-> candidates: [Adafruit PWM Servo Driver Library@3.0.2]
C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src -IC:\Users\zeusm\Documents\Arduino\libraries\Adafruit_PWM_Servo_Driver_Library C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\sketch\Clockception_Calibrate_Positions.ino.cpp -o nul
Alternatives for Adafruit_I2CDevice.h: [Adafruit BusIO@1.16.1]
ResolveLibrary(Adafruit_I2CDevice.h)
-> candidates: [Adafruit BusIO@1.16.1]
C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src -IC:\Users\zeusm\Documents\Arduino\libraries\Adafruit_PWM_Servo_Driver_Library -IC:\Users\zeusm\Documents\Arduino\libraries\Adafruit_BusIO C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\sketch\Clockception_Calibrate_Positions.ino.cpp -o nul
Using cached library dependencies for file: C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src\Wire.cpp
Using cached library dependencies for file: C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src\utility\twi.c
Using cached library dependencies for file: C:\Users\zeusm\Documents\Arduino\libraries\Adafruit_PWM_Servo_Driver_Library\Adafruit_PWMServoDriver.cpp
Using cached library dependencies for file: C:\Users\zeusm\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_BusIO_Register.cpp
Alternatives for SPI.h: [SPI@1.0]
ResolveLibrary(SPI.h)
-> candidates: [SPI@1.0]
Using cached library dependencies for file: C:\Users\zeusm\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp
Using cached library dependencies for file: C:\Users\zeusm\Documents\Arduino\libraries\Adafruit_BusIO\Adafruit_SPIDevice.cpp
Using cached library dependencies for file: C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src\SPI.cpp
Generating function prototypes...
C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++ -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src -IC:\Users\zeusm\Documents\Arduino\libraries\Adafruit_PWM_Servo_Driver_Library -IC:\Users\zeusm\Documents\Arduino\libraries\Adafruit_BusIO -IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\sketch\Clockception_Calibrate_Positions.ino.cpp -o C:\Users\zeusm\AppData\Local\Temp\3495317107\sketch_merged.cpp
C:\Users\zeusm\AppData\Local\Arduino15\packages\builtin\tools\ctags\5.8-arduino11/ctags -u --language-force=c++ -f - --c++-kinds=svpf --fields=KSTtzns --line-directives C:\Users\zeusm\AppData\Local\Temp\3495317107\sketch_merged.cpp
Compiling sketch...
"C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -Wno-error=narrowing -MMD -flto -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR "-IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino" "-IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\variants\eightanaloginputs" "-IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire\src" "-IC:\Users\zeusm\Documents\Arduino\libraries\Adafruit_PWM_Servo_Driver_Library" "-IC:\Users\zeusm\Documents\Arduino\libraries\Adafruit_BusIO" "-IC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI\src" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\sketch\Clockception_Calibrate_Positions.ino.cpp" -o "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\sketch\Clockception_Calibrate_Positions.ino.cpp.o"
Compiling libraries...
Compiling library "Wire"
Using previously compiled file: C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Wire\utility\twi.c.o
Using previously compiled file: C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Wire\Wire.cpp.o
Compiling library "Adafruit PWM Servo Driver Library"
Using previously compiled file: C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Adafruit_PWM_Servo_Driver_Library\Adafruit_PWMServoDriver.cpp.o
Compiling library "Adafruit BusIO"
Using previously compiled file: C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Adafruit_BusIO\Adafruit_BusIO_Register.cpp.o
Using previously compiled file: C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp.o
Using previously compiled file: C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Adafruit_BusIO\Adafruit_SPIDevice.cpp.o
Compiling library "SPI"
Using previously compiled file: C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\SPI\SPI.cpp.o
Compiling core...
Using precompiled core: C:\Users\zeusm\AppData\Local\Temp\arduino\cores\arduino_avr_nano_cpu_atmega328_122bf76278d7b93544f9ec540b89cf68\core.a
Linking everything together...
"C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -w -Os -g -flto -fuse-linker-plugin -Wl,--gc-sections -mmcu=atmega328p -o "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08/Clockception_Calibrate_Positions.ino.elf" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\sketch\Clockception_Calibrate_Positions.ino.cpp.o" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Wire\Wire.cpp.o" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Wire\utility\twi.c.o" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Adafruit_PWM_Servo_Driver_Library\Adafruit_PWMServoDriver.cpp.o" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Adafruit_BusIO\Adafruit_BusIO_Register.cpp.o" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Adafruit_BusIO\Adafruit_I2CDevice.cpp.o" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\Adafruit_BusIO\Adafruit_SPIDevice.cpp.o" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08\libraries\SPI\SPI.cpp.o" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08/..\..\cores\arduino_avr_nano_cpu_atmega328_122bf76278d7b93544f9ec540b89cf68\core.a" "-LC:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08" -lm
"C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08/Clockception_Calibrate_Positions.ino.elf" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08/Clockception_Calibrate_Positions.ino.eep"
"C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-objcopy" -O ihex -R .eeprom "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08/Clockception_Calibrate_Positions.ino.elf" "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08/Clockception_Calibrate_Positions.ino.hex"
Using library Wire at version 1.0 in folder: C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\Wire
Using library Adafruit PWM Servo Driver Library at version 3.0.2 in folder: C:\Users\zeusm\Documents\Arduino\libraries\Adafruit_PWM_Servo_Driver_Library
Using library Adafruit BusIO at version 1.16.1 in folder: C:\Users\zeusm\Documents\Arduino\libraries\Adafruit_BusIO
Using library SPI at version 1.0 in folder: C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\libraries\SPI
"C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avr-gcc\7.3.0-atmel3.6.1-arduino7/bin/avr-size" -A "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08/Clockception_Calibrate_Positions.ino.elf"
Sketch uses 7952 bytes (25%) of program storage space. Maximum is 30720 bytes.
Global variables use 483 bytes (23%) of dynamic memory, leaving 1565 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM5" -b115200 -D "-Uflash:w:C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08/Clockception_Calibrate_Positions.ino.hex:i"
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Users\zeusm\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM5
Using Programmer : arduino
Overriding Baud Rate : 115200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 4.4
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\zeusm\AppData\Local\Temp\arduino\sketches\C258AD9824F8B9EF821DB9FECA54FD08/Clockception_Calibrate_Positions.ino.hex"
avrdude: writing flash (7952 bytes):
Writing | ################################################## | 100% 3.01s
avrdude: 7952 bytes of flash written
avrdude done. Thank you.
Code run:
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver board1 = Adafruit_PWMServoDriver(0x40);
Adafruit_PWMServoDriver board2 = Adafruit_PWMServoDriver(0x41);
Adafruit_PWMServoDriver board3 = Adafruit_PWMServoDriver(0x42);
#define SERVOMIN 544 // This is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX 2400 // This is the 'maximum' pulse length count (out of 4096)
#define SERVO_FREQ 50 // Analog servos run at ~50 Hz updates
int number; // number command
///////////////////////////////////////////////////////////////////////////////////
void setup() { // put your setup code here, to run once:
Serial.begin(9600); // initialize Serial connection
board1.begin(); // Initialize servo control boards
board2.begin();
board3.begin();
board1.setOscillatorFrequency(27000000);
board2.setOscillatorFrequency(27000000);
board3.setOscillatorFrequency(27000000);
board1.setPWMFreq(SERVO_FREQ); // Analog servos run at ~50 Hz updates
board2.setPWMFreq(SERVO_FREQ);
board3.setPWMFreq(SERVO_FREQ);
Serial.println("Ready for command");
yield();
}
///////////////////////////////////////////////////////////////////////////////////
void loop() { // put your main code here, to run repeatedly:
while(Serial.available() > 0){ // see if a command has been sent
number = Serial.parseInt(); // turn command into integer
Serial.print(number);
Serial.println(" sent");
angleToPulse(number);
}
delay(100);
}
///////////////////////////////////////////////////////////////////////////////////
void angleToPulse(int ang){
int pulse1 = map(ang, 0, 180, SERVOMIN, SERVOMAX); // map angle of 0 to 180 to Servo min and Servo max
int pulse2 = int(float(pulse1) / 1000000 * SERVO_FREQ * 4096);
Serial.print("Angle: "); Serial.print(ang);
Serial.print(" pulse: "); Serial.println(pulse2);
board1.setPWM(1, 0, pulse2);
delay(100);
}
///////////////////////////////////////////////////////////////////////////////////