Pages: [1]   Go Down
Author Topic: Arduino Duemilanove-Can't Upload  (Read 1097 times)
0 Members and 1 Guest are viewing this topic.
California, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 33
I'm a 13 year old that's interested in anything electronic/robotic! My ROBLOX username is 058606.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Help! I'm trying to upload a sketch (1536 bytes) to my Arduino Duemilanove. Whenever I try to upload, I get this message:

avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

EDIT: On one, it doesn't show any error messages, but the TX light on the Arduino stays on, and it seems like it's frozen.
EDIT TO MY EDIT: I looked at the serial monitor, and discovered that there's an infinite loop in my previous program! How do I stop it? Do I have to wipe the MCU and put the bootloader back on?
This happens on both of my Arduino Duemilanoves smiley-eek! One of them has never been used until now. I'm using the latest version of the Arduino software (0022) on a Windows 7 64 bit machine. I would appreciate any help I get on this subject! smiley-cry

Here is my sketch:
Code:
/*
  Sketch Author: xxxxxxxx
  Date Started: 2/12/2011
  Date Finished: TBD
  
  Desc: This sketch detects how many (not which) buttons are
  pressed, and displays that number on the 7 segment display.
*/


//define pin numbers
//7 segment display
const int a = 2;
const int b = 3;
const int c = 4;
const int d = 5;
const int e = 6;
const int f = 7;
const int g = 8;
//buttons
const int b1 = 9;
const int b2 = 10;
const int b3 = 11;
const int b4 = 12;

//define varables
int b1State = 0;
int b2State = 0;
int b3State = 0;
int b4State = 0;
int numPressed = 0;

void setup()
{
  pinMode(a, OUTPUT);
  pinMode(b, OUTPUT);
  pinMode(c, OUTPUT);
  pinMode(d, OUTPUT);
  pinMode(e, OUTPUT);
  pinMode(f, OUTPUT);
  pinMode(g, OUTPUT);
  pinMode(b1, INPUT);
  pinMode(b2, INPUT);
  pinMode(b3, INPUT);
  pinMode(b4, INPUT);
}

void loop()
{
  if (digitalRead(b1) == HIGH) //find out if button 1 is pressed
  {
    b1State = 1;
  }
  else
  {
    b1State = 0;
  }
  
  if (digitalRead(b2) == HIGH) //find out if button 2 is pressed
  {
    b2State = 1;
  }
  else
  {
    b2State = 0;
  }
  
  if (digitalRead(b3) == HIGH) //find out if button 3 is pressed
  {
    b3State = 1;
  }
  else
  {
    b3State = 0;
  }
  
  if (digitalRead(b4) == HIGH) //find out if button 4 is pressed
  {
    b4State = 1;
  }
  else
  {
    b4State = 0;
  }
  
  numPressed = b1State + b2State + b3State + b4State; //add up how many buttons are pressed
  
  switch (numPressed)
  {
    case 1: //displays the number 1
      digitalWrite(a, LOW);
      digitalWrite(b, HIGH);
      digitalWrite(c, HIGH);
      digitalWrite(d, LOW);
      digitalWrite(e, LOW);
      digitalWrite(f, LOW);
      digitalWrite(g, LOW);
    case 2: //displays the number 2
      digitalWrite(a, HIGH);
      digitalWrite(b, HIGH);
      digitalWrite(c, LOW);
      digitalWrite(d, HIGH);
      digitalWrite(e, HIGH);
      digitalWrite(f, LOW);
      digitalWrite(g, HIGH);
    case 3: //displays the number 3
      digitalWrite(a, HIGH);
      digitalWrite(b, HIGH);
      digitalWrite(c, HIGH);
      digitalWrite(d, HIGH);
      digitalWrite(e, LOW);
      digitalWrite(f, LOW);
      digitalWrite(g, HIGH);
    case 4: //displays the number 4
      digitalWrite(a, LOW);
      digitalWrite(b, HIGH);
      digitalWrite(c, HIGH);
      digitalWrite(d, LOW);
      digitalWrite(e, LOW);
      digitalWrite(f, HIGH);
      digitalWrite(g, HIGH);
    default: //displays the number 0
      digitalWrite(a, HIGH);
      digitalWrite(b, HIGH);
      digitalWrite(c, HIGH);
      digitalWrite(d, HIGH);
      digitalWrite(e, HIGH);
      digitalWrite(f, HIGH);
      digitalWrite(g, LOW);
  }
}
[code/]
« Last Edit: February 13, 2011, 11:32:28 am by 058606 » Logged

const bool loveElectronicsRelatedThings = true;

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6133
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Serial loops tend to cause this problem.

You need to manually reset the Arduino immediately before the code upload begins.  Click the upload button and when you see the message like "Sketch size:  xxxx bytes (out of xxx bytes)" press the Arduino's reset button.

The timing might vary (like 1-2 seconds after the message.)
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

California, USA
Offline Offline
Newbie
*
Karma: 0
Posts: 33
I'm a 13 year old that's interested in anything electronic/robotic! My ROBLOX username is 058606.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Serial loops tend to cause this problem.

You need to manually reset the Arduino immediately before the code upload begins.  Click the upload button and when you see the message like "Sketch size:  xxxx bytes (out of xxx bytes)" press the Arduino's reset button.

The timing might vary (like 1-2 seconds after the message.)

Thanks for your help, but it turns out it was a simple problem. The software was trying to upload to an Arduino Uno! I fixed it in Tools - Board and it uploaded perfectly.
Logged

const bool loveElectronicsRelatedThings = true;

Pages: [1]   Go Up
Jump to: