any thoughts on why this is necessary. The arduino script is very simple and I dont understand why it requires the reset to work
the script:
/*
isadora triggering arduino
in isadora the key watches will sent 1-4 to the arduino, and the arduino will blink accordingly
created by r. holsopple
http://31down.org
2009
*/
int ledPin = 12; //the LED on the arduino board
byte incoming_byte; // raw user input
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(9600); //set isadora serial out to this speed under communications, make sure serial port is enabled
Serial.println("isadora control of arduino");
Serial.println(" do it manually with the keyboard");
// blink twice on startup
digitalWrite(ledPin, HIGH); // blink twice
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, HIGH);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
}
void loop()
{
if (Serial.available() > 0) {
// read the incoming byte:
incoming_byte = Serial.read();
Serial.println(incoming_byte);
switch (incoming_byte) {
case 49://ascii 49 is the '1' key on the keyboard
Serial.println(" received a '1'");
digitalWrite(ledPin, HIGH); // blink once
delay(500); //pause for 100 milliseconds
digitalWrite(ledPin, LOW);
break;
// break is optional
case 50://ascii 50 is the '2' key on the keyboard
Serial.println(" received a '2'");
digitalWrite(ledPin, HIGH); // blink twice
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, HIGH);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
break;
//********for all dousers
case 51://ascii 51 is the '3' key on the keyboard
Serial.println(" received a '3'");
digitalWrite(ledPin, HIGH); // blink three times
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, HIGH);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, HIGH);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
break;
// break is optional
case 52://ascii 52 is the '4' key on the keyboard
Serial.println(" received a '4'");
digitalWrite(ledPin, HIGH); // blink four times
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, HIGH);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, HIGH);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, HIGH); \
delay(500); //pause for 500 milliseconds
digitalWrite(ledPin, LOW);
break;
default:
// if nothing else matches, do the default
// default is optional
Serial.println("not for arduino");
}
}
}
DON'T do this one. Neither the reset nor the arduino bootloader does not reset the watchdog, and this leads to a loop where the arduino resets, starts the bootloader, and resets again before a sketch can be downloaded. Sometimes you can break the loop using power-on instead of reset to load a new sketch, but it isn't ... pleasant.
(I should say: "many versions of the arduino bootloader do not reset the watchdog." There are a couple that DO.)
DON'T do this one. Neither the reset nor the arduino bootloader does not reset the watchdog
That's a bit strong given the fact that it's fairly easy to shut off the watchdog at the top of setup.
But it's not. Depending on the bootload, the arduino spends several seconds flashing the leds in a "healthy" sequence and/or checking for serial traffic to see whether it should upload a new sketch or start the existing one. If you've gotten it to reset by setting a short watchdog timeout and going into a loop, you might never get to the setup in your sketch before the next watchdog reset happens.
DON'T do this one. Neither the reset nor the arduino bootloader does not reset the watchdog
That's a bit strong given the fact that it's fairly easy to shut off the watchdog at the top of setup.
But it's not.
Ah. Got it. I'm using an Arduino compatible board that doesn't have this problem. I assumed all boards behaved like mine.
It may be possible to avoid this problem by using the "Interrupt and System Reset Mode". It all depends on how the processor behaves if the watchdog is turned off in the ISR.
If I understand the reset correctly, the physical button resets it by bringing the RESET pin LOW. Is it possible to connect the reset pin to one of the digital IO pins and use a digitalWrite(connect_to_reset_pin, LOW) ?
If I understand the reset correctly, the physical button resets it by bringing the RESET pin LOW. Is it possible to connect the reset pin to one of the digital IO pins and use a digitalWrite(connect_to_reset_pin, LOW) ?
This will work but I would diode-or the output. I would configure the pin
as an output right before the digitalWrite command rather than in the setup
although it should not matter with the diode.
You should only set the pin low and then do a while(1) {};
Once you set the pin low the ATmega will reset and the default state of the pin will be an input (open circuit). If you set the pin low then high there is a chance that the reset pin will not be low long enough to reset the ATmega.
Connect the anode to the reset line and the cathode to the ATmega pin.
The trick will be figuring out how to only do the reset 'once per power cycle'. So the 'first' time the sketch runs, it sets some flag, then resets itself. The 'second' time it checks the flag state, and doesn't reset. Tricky.
Also you don't hold the pin HIGH using the diode, that is done with a pull-up resistor that is probably already on the board. What board are you using?
The trick will be figuring out how to only do the reset 'once per power cycle'. So the 'first' time the sketch runs, it sets some flag, then resets itself. The 'second' time it checks the flag state, and doesn't reset. Tricky.
If that needs to be done you may need to modify the bootloader to detect the
source of the interrupt and clear the flags.
Hi all.
Being a bit new to Arduino, I have a Arduino BT (Bluetooth) witch seems to require hit the rest buton everytime I upload to the board, or everytime I hit run on Processing. since I'm putting the Arduino in a closed box, I want to connect an exterior button so I can reset from outside. Any ideas how to do it? Can this be done from the code like previously anounced here?
Thank you for your help