Pages: [1]   Go Down
Author Topic: arduino uno won't remember sketch  (Read 1023 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I,ve upladed a sketch succesfully to my arduino uno and I connected a powersupply.
However every time a disconnect the USB cable from the arduino it does not remember my sketch.
Does anyone have an idea what might be wrong?
Thanks, Wybe
Logged

Leeds, England
Offline Offline
God Member
*****
Karma: 14
Posts: 586
Quick, chuck it in the bin before the boss finds out...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Unfortunately I can't actually help you with this problem, but could you confirm (from the reverse of the board) which version of the board, and was it 'Made in Italy' or 'Designed in Italy'?
Logged

Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

it is made in Italy and it is a Uno R3
Logged

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

Very early on the Uno's bootloader had a situation where it would "forget" the loaded sketch.  However that was fixed years before the R3 came out.  Something strange must have happened for your official Arduino board to have such an old bug.

As long as you purchased it from an authorized distributor (e.g. not eBay or Amazon), you should be able to return it for a replacement.
Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,I will do that but first I will try another powersupply and another uno to see if `i can locate the problem.ß
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well, i've tried a different arduino and another power supply, but the problem occurs on both arduino's.
Then I uploaded a different sketch and the arduino remembered it.
So now i think the problem is in the sketch.
I'm new at this , does anyone see a problem?
Thanks a lot.


Code:
// SingleButtonMIDI.ino
// Driving MIDI using a single button
// Rob Ives 2012
// This code is released into the Public Domain.
 
#include <MIDI.h>
 
#define KEY 8
#define LED 13
 
int keyispressed = 0; //Variable. Is the key currently pressed?
int noteisplaying = 0; //Variable. Is the Note currently playing?
 
void  setup() //The Setup Loop
{
  pinMode(LED, OUTPUT);  //Set pin 13 , the led, to output
  pinMode(KEY, INPUT);  //Set pin 8 to input to detect the key press
  MIDI.begin(); //initialise midi library
}
//---------------------------------------------
void loop() //the main loop
{
  keyispressed = digitalRead(KEY); //read pin 8
 
  if (keyispressed == HIGH){ //the key on the board is pressed
    digitalWrite(LED, HIGH); //set the LED to on.
    if(!noteisplaying){ //if the note is not already playing send MIDI instruction to start
       MIDI.sendNoteOn(36,127,1);  // Send a Note (pitch 36 (C2), vel.127  ch. 1)
       noteisplaying = 1; // set the note playing flag to TRUE
    }
  }
  else{
    digitalWrite(LED,LOW); // the key is not pressed. Turn off the LED
    if(noteisplaying){ //if the note is currently playing, turn it off
      MIDI.sendNoteOff(36,0,1);   // Stop the note
      noteisplaying = 0; // clear the note is playing flag
    }
  }
}


Moderator edit: [code] [/code] tags added.
« Last Edit: July 19, 2013, 08:49:18 pm by Coding Badly » Logged

Offline Offline
Edison Member
*
Karma: 64
Posts: 2484
The last thing you did is where you should start looking.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure about the power problem but suggest adding the line.

pinMode(KEY, INPUT);  //Set pin 8 to input to detect the key press
digitalWrite(KEY,HIGH); //turn on pull-up resistor
Logged

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

Where did you buy the board(s) from?


So now i think the problem is in the sketch.
This occurs very rarely.


Quote
digitalWrite(KEY,HIGH); //turn on pull-up resistor
Good advice, but...
  if (keyispressed == HIGH){ //the key on the board is pressed
This implies that the button is configured for a pull-down, not a pull-up.
Logged

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

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks guys, I bought the arduino's at a shop called Conrad and this is a normal shop in Holland for electronics.
The sketch itself works fine, everytime i push the button a midi note is send and played.
But always when I remove the usb cable and then put it back,the sketch is gone, and I have to upload it again.
I've uploaded the "blink sketch" and when I remove and put back the usb cable the arduino remembers the sketch.
Thanks a lot for thinking with me , I don't have a clue.
Logged

Halifax, Canada
Offline Offline
Jr. Member
**
Karma: 0
Posts: 50
Don't anthropomorphize computers. They hate that.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I wonder if the problem might be with the USB controller on your computer... Did you try plugging into a different port?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello everybody, I stumbled on this one:

Hi

It turned out that the lights flashing on the board were not indicating output from the TX pin but output into the USB. Having power cycled if I waited for long enough for the USB Serial to start working on my computer again it flashed as expected. Once I plugged in the MIDI interface I had no problems!

Sorry I can't be of more help.

M

This was exectly the case with me.
Everything is working fine now.
Again I would like to thank everybody and I want to apologize for your complete waste of time with me,sorry.
Wybe
Logged

Pages: [1]   Go Up
Jump to: