I'm new to Arduino, i wanted to get a servo working, i was writing this program and it worked fine:
#include <Servo.h>
int pos = 0; // variable to store the servo position
int servoPin= 9;
int servoDelay=25;
Servo myPointer;
void setup()
{
Serial.begin(9600);
myPointer.attach(servoPin); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos=15; pos<=170; pos=pos+1) {
myPointer.write(pos);
delay(servoDelay);
}
for (pos=170; pos>=15; pos=pos-1) {
myPointer.write(pos);
delay(servoDelay);
}
}
Then i would change the speed or really anything and i would get an error on the Arduino, the servo kept running the above program.
The error:
Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Uno"
Sketch uses 928 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:C:\Users\dukat\AppData\Local\Temp\arduino_build_870122/Blink.ino.hex:i
avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"
Using Port : COM3
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can't set com-state for "\.\COM3"
avrdude done. Thank you.
An error occurred while uploading the sketch
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Even at times the Arduino would say it worked but it wouldn't.
i dont have an external power to the 1 servo...could this be causing a problem ?