2

I was playing around with my Arduino Uno R3 board with Sublime Text 2 & 'Stino' as IDE
I am not sure if it is my code is the problem or if I broke something...
I pressed upload while another sketch didn't finish uploading, even the original Arduino IDE can't upload new sketches anymore!

This is my code:

// singleServo.ino

#include <Servo.h>

Servo servo;
const int button = 2;
const int led = 13;
const int buzzerPin = 10;
const int duration = 180;

int stateLED = LOW;
int previous = LOW;

void setup() {
    pinMode(led, OUTPUT);
    pinMode(button, INPUT);
    pinMode(buzzerPin, OUTPUT);
    Serial.begin(9600);
}

void loop() {
    int stateButton;

    stateButton = digitalRead(button);

    if (stateButton == LOW && previous == LOW) {
        if (stateLED == HIGH) 
        { 
            stateLED = LOW; 
            initAction(duration);
        }
        else 
        { 
            stateLED = HIGH;
        }
    }

    digitalWrite(led, stateLED);
    previous = stateButton;
    servo.detach();
}

void initAction(int time_iA){
    tone(buzzerPin, 523, 200);
    delay(200);

    shiftServo(180, time_iA);

    tone(buzzerPin, 262, 200);
}

void shiftServo(int angle, int time_sS) {
    servo.attach(9);
    delay(500);
    int position;

    for(position=0; position <= angle; position += 1)
    {
        servo.write(position);
        delay(time_sS / 180);
        Serial.println(servo.read());
    }
    // for(position=angle; position >= 0; position -= 1)
    // {
    //  servo.write(position);
    //  delay(time_sS / 90);
    // }
}

I am a newbie with all things Arduino - Please help!

EDIT: After rebooting the system (Ubuntu Linux 14.04) everything was working just fine again!
But I'm going to take the serial functions out too.

migrated from electronics.stackexchange.com Sep 7 '14 at 20:43

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

  • Have you tried to power everything down, including the host PC, then upload using the Arduino IDE? What OS are you using? – gbulmer Sep 7 '14 at 20:40
  • Check task manager or top or whatever for any orphaned avrdude processes – BrettAM Sep 7 '14 at 21:28
  • I know this is really basic, and don't be offended, but have you pressed the buiild button and verified it builds before upload? - Also please double check that the arduino is attached to the USB port assigned in the buildtool. – Magic-Mouse Sep 8 '14 at 8:23
1

You have to wait for the first and all other uploads to fail.

If you are not sure, a reboot is the most reliable solution.

Also note that if your sketch sends a lot of data over serial, a manual reset of the board may be needed.

  • Rebooting helped. But what exactly did I do wrong? Was it the Serial or because I stopped that Upload? Should I stop using the Sublime + Stino IDE? – robertgzr Sep 8 '14 at 8:48
  • the problem is normally uploading is an external script has not properly stopped, and its timeout are very high. Normally killing the process may leave the serial port "busy" (unplua and replug USB solve that), but in arduino ide there is no "kill switch" and you have to wait (note t hat being external command is indipendant from the ide). Seems like stino does the same. About the IDE, use whatever you want, but before posting here check if arduino ide has same poblem! – Lesto Sep 8 '14 at 8:58
  • I checked just that. I couldn't get any sketches uploaded from both ides – robertgzr Sep 8 '14 at 9:00
  • yes, that case is a "race condition" over the serial; as serial port can be used only by one program at time, until all precedent upload fail (a lot of timeout time, about 20/30sec for EVERY upload in queue) you can't upload. Also notice removing Serial from sketch does not help in that case, as it is a pc issue. Serial in sketch is problematic only when write too much, but a manual board reset is easyer to do, when you'll learn the rght timing :) – Lesto Sep 8 '14 at 9:04
  • I was reading about that manual reset somewhere else but I couldn't get it at the right time^^ thanks anyway for the explanation – robertgzr Sep 8 '14 at 9:08
1

I've got the same problem on my Ubuntu. Eventually, I was stuck at every uploading, even after unplugging+replugging the device.

Killing all avrdude process, remove the problem.

sudo killall avrdude

or with new IDEs:

sudo killall avrdude_bin
0

I had this happen to me on an UNO R3. I solved the issue by disabling Bluetooth on my laptop. It was causing a conflict on COM5.

I had ruled out the board, cable, and IDE. Finally noticed in Device Manager that COM5 had entries (one being the Arduino and the other being Bluetooth)

Hope that helps someone else that might have this issue in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.