Go Down

Topic: arduino uno won't remember sketch (Read 1 time) previous topic - next topic

visavis

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

dannable

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'?
Beginners guide to using the Seeedstudio SIM900 GPRS/GSM Shield

visavis

it is made in Italy and it is a Uno R3

James C4S

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.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

visavis

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

visavis

#5
Jul 14, 2013, 02:33 pm Last Edit: Jul 20, 2013, 03:49 am by Coding Badly Reason: 1
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: [Select]
// 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.

LarryD

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
The way you have it in your schematic isn't the same as how you have it wired up!

James C4S

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.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

visavis

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.

MLeBlanc

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

visavis

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

Go Up