Arduino Stuck Uploading

Hey guys,

I am trying to complete a fairly simple project as a gift for someone and all that I need to be able to do is get a servo to spin when someone waves something in front of an IR sensor.

So I have a full rotation servo and I want it to continue to rotate for a second or two whenever the IR sensor is tripped.

Well I had a few sketches that I was using and they were uploading just fine. Then when I changed the way my object was going to be connected to my servo I decided to change the rotation from partial to full.

So I quickly made the fairly simple change of removing the for loops to cause the servo to turn back and forth and just told it to spin.

I verified the code and it fully compiled. However when I went to upload it, the upload never appears to be finishing. I verified that the usb port selected is the correct port and that the board I was using was also correctly selected. I am using an Arduino Uno on my Mac using OS X version 10.11.4

I have never had this problem before. I then reset my Mac, twice, as well as unplugged and re-plugged in the usb cord. I also pressed the manual reset switch on the Arduino board itself multiple times. I have been tying to let it upload now for about 10 minutes and it still isn't doing anything useful.

Also anytime that I trip the IR sensor the old code runs which indicates to me that it is still on there.

The upload bar is full as well. I am at a loss as to what I can do. In about 2 weeks I am going to a workshop called RockOn! in Virginia to build a payload that will go on a sounding rocket and the payload uses an Arduino so I really need to fix this as soon as possible.

I don't know if I am using the latest Arduino IDE but I think that I am and I will check to see if there are any updates that I can install.

Please help me. For reference purposes I have included the code that I was trying to run.

// Type code here for setting variables and including libraries and such.

/********************************

  • Servo Setup Code
    ********************************/
    #include <Servo.h> //enters the servo library

Servo myservo; //Creates a variable for a servo to be controlled

int pos = 0; // this is a variable to store the position of the servo

/**********************************

  • IR Setup Code
    **********************************/

int IRsensorPin = A2;
int IRsensorValue = 0;

int movePuppet = 400;

// Create a reset pin to reset the program
int resetPin = 12;

void setup() {
digitalWrite(resetPin, HIGH);
delay(200);
pinMode(resetPin, OUTPUT);
Serial.begin(9600);

myservo.attach(9); // this places the control pin for the servo to pin 9

}

void loop() {
IRsensorPin = analogRead(A2);
Serial.print("I see something ");
Serial.print(IRsensorPin);
Serial.println(" undescribed units away!!!");
delay(50);
//myservo.write(20);

if (IRsensorPin > movePuppet){
spin();
}

}

/************

  • Functions
    ***********/

void spin(){

myservo.write(20);
delay(1500);
digitalWrite(resetPin, LOW);
}

Thank you for any and all help that you can provide.

Use code tags (</>) for code.

Try uploading something simple like a blink sketch. Does that upload? If it does you know it's something with your code. If not, it's an issue with either the board or the software.

Hi,

Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

What does the RESET output do?
Why reset anything, the loop program continues "looping" it doesn't run once like the setup.

Is your servo a 0-180drg servo, or a continuous servo?

How are you powering the servo?
I hope not off the 5V on the UNO, it cannot supply the current you need for reliable.

Thanks.. Tom.. :slight_smile:

I will work at getting a picture of the circuit and post that as soon as I have it.

As for the servo it is a continuous rotation servo and I am powering it off of the 5 V pin on the arduino.

I chose this because I don't need much out of the servo or the arduino. I will explain what the purpose is in a minute.

now when it comes to the reset output, I wrote that into the code so that the servo would stop spinning. I am fairly new to arduino and definitely to servo control. I had different code for a 0-180drg servo but I didn't feel that that servo was powerful enough to do what I wanted so I switched to my continuous servo.

The problem when doing that was that once the servo turned back and forth 2 times, which came from the code for the other servo yet still initially worked with this one, it would continue to spin and never stop. So I needed a way to get it to stop spinning and when I pressed the reset button on the arduino itself my goal was accomplished. That is why I have the reset in the code so that it will stop the servo from rotating for forever.

So the whole purpose of this project was to make a marionette move just a little bit when someone waved in front of an IR sensor. So that is the purpose for the reset, so as not to have the marionette forever moving.

So I will read the post about how to post and I will get the picture as requested.

In all truth this project of mine can wait it doesn't mean that much to me right now. What I am worried about is not getting this problem fixed because I was not able to load even the simplest of code and I need this to work by the 17th of June. This all happened today and I really need to get it fixed.

Thank you so far for the feedback it is greatly appreciated. I look forward to hearing more about how I might be able to fix this problem.

Thanks,

Chris

Here is the code with the appropriate code tags. Sorry about this earlier.

I also made a quick schematic of the circuit that i am using via the fritzing software. It is not pretty but it does show where all the wires are connected. I am uploading a screen shot of it because it didn't upload the file properly

Again this project itself is not my true concern however I can't get anything to load and that will really hurt me at the workshop that I am going to in about 11 days.

Thanks again for all the help.

// Type code here for setting variables and including libraries and such.

/********************************
 * Servo Setup Code
 ********************************/
 #include <Servo.h> //enters the servo library

 Servo myservo; //Creates a variable for a servo to be controlled

 int pos = 0; // this is a variable to store the position of the servo

/**********************************
 * IR Setup Code
 **********************************/

 int IRsensorPin = A2;
 int IRsensorValue = 0;

 int movePuppet = 400;

 // Create a reset pin to reset the program
 int resetPin = 12;

void setup() {
  digitalWrite(resetPin, HIGH);
  delay(200);
  pinMode(resetPin, OUTPUT);
  Serial.begin(9600);
  
  myservo.attach(9); // this places the control pin for the servo to pin 9
  
  
}

void loop() {
  IRsensorPin = analogRead(A2);
  Serial.print("I see something ");
  Serial.print(IRsensorPin);
  Serial.println(" undescribed units away!!!");
  delay(50);
  //myservo.write(20);

  if (IRsensorPin > movePuppet){
    spin();
  }
  
}

Hi,

Have you tried to load a blink example sketch?
How are you switching the RESET, it may be trying to reset all the time.
Remove the reset device and try.

This is a good explanation and sample sketch;

Use a servo value of 90 as in 90deg to get the servo to stop, or near stop.

Forget fritzy, hand draw and photograph or scan it. With pin numbers and component names.

Hope this helps... Tom.. :slight_smile:

So I just tried to upload the example sketch that is in the link that you provided Tom and it is running into the exact same problem. I had tried some other super simple sketches as well.

As for the reset, I don't think that this is the problem as it was working in the first few sketches that I used it it. The website that I used to learn the reset is here:

I followed those instructions and it worked great before. I would wave my hand in front of the IR sensor and the servo would spin back and forth and then stop whereas before I put in the reset code it would spin back and forth and then spin around and around until I pushed the reset button or disconnected power. I ran it many times with the reset code.

However do to the slight drift of the servo I was using I found a different way to connect it to the marionette so that it could just continually rotate and work the same. This is when I changed the code to what you see and ran into the forever uploading issue.

A pop up box telling me there was updates for my boards and something else popped up so I decided to update the software hoping that that would help but it didn't in fact now it still uploads endlessly and also says this:

avrdude: no progammer has been specified on the command line or the config file
Specify a programmer using the -c option and try again

I have to go to handle a few things right now but I will make that hand drawn sketch as soon as I can and I will upload it as well.

Thank you for your patience.

Chris

(deleted)

So I removed one of the ! in the serial print line and it still has the same issue. Won't finish uploading and displays error code:

avrdude: no programmer has been specified on the command line or the config file
Specify a programmer using the -c option and try again

The only difference I have been able to notice is now there is no longer the blue upload bar at the bottom right of the arduino IDE.

I was really hoping that would fix it.

Thank you though.

Chris

Hi,

A pop up box telling me there was updates for my boards and something else popped up so I decided to update the software hoping that that would help but it didn't in fact now it still uploads endlessly and also says this:

Weeellllll....new information.
Delete the IDE you have and reload it.

Tom....... :slight_smile:

Weeellllll....new information.
Delete the IDE you have and reload it.

That gave me a good laugh so thank you Tom.

I did uninstall and re-install the ide and it did fix the problem of the error code I was getting.

avrdude: no programmer has been specified on the command line or the config file
Specify a programmer using the -c option and try again

However the same thing happened as always.

But then I tried to do some different troubleshooting that I for the life of me don't know why I didn't try earlier.

The first thing that I did was I tried to upload the code to a different arduino board and to my great surprise it worked. Now nothing was attached to the board but it loaded fully.

After this I tried the original board again with everything still connected and I ran into the same problem.

At this point I removed all the wires so only the board was connected to the computer and I tried to load the sketch and it worked. Then when I plugged everything back into the board it acted as desired.

I tried to move the ground wire to each ground spot and re-uploading the code but that didn't change anything. So far as long as everything is plugged into the board it will not properly upload but if I unplug everything it loads just fine and then when the servo and IR sensor are plugged back in they work just fine when power is delivered to the board.

I even tried plugging all the devices into the alternate board and then (which is an off brand arduino uno from micro center) try to upload the code but it runs into the same problem as well with not being able to finish the upload.

So I am starting to think that something in either the servo or the IR sensor is causing a problem uploading the code that doesn't prevent them from working once the code is uploaded.

So now I am going to continue testing different ways to upload the code with different external devices plugged in and see what happens.

Does anyone have an explanation as to what might cause this.

Thank you again for all the help,

Chris

So last update for the night (I think lol :grin: )

I started to take things out and learned that if the IR sensor was plugged in it would cause the problem of sticking on the upload.

The servo worked just fine.

So after the I started to mess with the wires that were connecting the IR sensor to the board and I think I figured it out.

Any time that the ground wire from the IR sensor was in the slot of the breadboard where I originally plugged it in this problem occurred.

I moved the ground wire to an open ground spot on the board and it uploaded just fine. I tried it in a different spot on the breadboard and it still worked. I even uploaded the code without the ground wire plugged in (and then promptly removed the power once it was done) and that worked as well.

Finally I tried to plug it into the original spot on the breadboard just to see what might happen and the error occurred as it had so many times before.

So to the best to my knowledge I have a faulty spot on my breadboard. I am hoping that this is all that it is. I would love to hear your guys' thoughts on this.

Thanks so much for everything along the way.

Chris