dudas de novato con arduino

hoola, pues acabo de recibir mi arduino duemilanove, me baje los archivos y he echo parpadear el led al ritmo que yo quiera...,hasta aqui todo bien , pero seguí investigando y me dio por pulsar el boton s1 (el cual yo pensaba y pienso que es el boton reset) y pense que borraria todo el codigo del atmega, pero lo pulso y el led sigue parpadeando...sino es el boton de reset para que es ese boton?

pd: segun enchufe mi duemilanove al usb el led L tambien parpadeaba sin cesar aunque no a un ritmo fijo.. a que se debe?

muchas gracias :slight_smile:

Al conectar una batería, adaptador de voltaje o el USB se reinicia el Arduino, si quieres saber más sobre el reinicio, ve este post:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1283261661

...no lo acabo de entender porque yo le doi al boton reset de mi duemilanove y el codigo que tenia cargado sigue funcionando...

tambien cargue el codigo de Debounce que hace de un pulsador un interruptor ,pero solo me funciona comopulsador...es decir el led no se queda encendido...tendre una arduino defectuosa? :-[

Al reiniciar no borras el programa cargado en el microcontrolador, solo lo reinicias, osea corre nuevamente:

void setup()   
{                
}
void loop()                     
{
}

del programa guardado, es como cuando reinicias tu pc, se carga en sistema operativo y todo lo que tengas guardado.

saludos

muchisimas gracias por tu ayuda... y siento si soi algo pesado...pero entonces de que vale reiniciar el atmega?... :-?

otras preguntas:

-como puedo borrar lo que tenga en la memoria completamente?
-el ejemplo "debounce" se supone que crea de un pulsador un interruptor con el circuito bien realizado (con la resistencia y demas..) ..a mi nose porque no me funciona y simplemente el pulsador actua como tal , encendiendo el led cuando lo pulso y apagandolo cuando dejo de pulsarlo... a que puede ser debido? el codigo a continuacion:

/*
Debounce

Each time the input pin goes from LOW to HIGH (e.g. because of a push-button
press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's
a minimum delay between toggles to debounce the circuit (i.e. to ignore
noise).

The circuit:

  • LED attached from pin 13 to ground

  • pushbutton attached from pin 2 to +5V

  • 10K resistor attached from pin 2 to ground

  • Note: On most Arduino boards, there is already an LED on the board
    connected to pin 13, so you don't need any extra components for this example.

created 21 November 2006
by David A. Mellis
modified 3 Jul 2009
by Limor Fried

http://www.arduino.cc/en/Tutorial/Debounce
*/

// constants won't change. They're used here to
// set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin

// Variables will change:
int ledState = HIGH; // the current state of the output pin
int buttonState; // the current reading from the input pin
int lastButtonState = LOW; // the previous reading from the input pin

// the following variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long lastDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 50; // the debounce time; increase if the output flickers

void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
}

void loop() {
// read the state of the switch into a local variable:
int reading = digitalRead(buttonPin);

// check to see if you just pressed the button
// (i.e. the input went from LOW to HIGH), and you've waited
// long enough since the last press to ignore any noise:

// If the switch changed, due to noise or pressing:
if (reading != lastButtonState) {
// reset the debouncing timer
lastDebounceTime = millis();
}

if ((millis() - lastDebounceTime) > debounceDelay) {
// whatever the reading is at, it's been there for longer
// than the debounce delay, so take it as the actual current state:
buttonState = reading;
}

// set the LED using the state of the button:
digitalWrite(ledPin, buttonState);

// save the reading. Next time through the loop,
// it'll be the lastButtonState:
lastButtonState = reading;
}

MUCHISIMAS GRACIAS :slight_smile:

Espero no precipitarme, pero no funciona. Mejor usa este código:

int switchPin = 2; // switch is connected to pin 2
int led1Pin = 13;

int val; // variable for reading the pin status
int val2; // variable for reading the delayed/debounced status
int buttonState; // variable to hold the button state

int lightMode = 0; // Is the light on or off?

void setup() {
pinMode(switchPin, INPUT); // Set the switch pin as input

pinMode(led1Pin, OUTPUT);
buttonState = digitalRead(switchPin); // read the initial state
}

void loop(){
val = digitalRead(switchPin); // read input value and store it in val
delay(10); // 10 milliseconds is a good amount of time
val2 = digitalRead(switchPin); // read the input again to check for bounces
if (val == val2) { // make sure we got 2 consistant readings!
if (val != buttonState) { // the button state has changed!
if (val == LOW) { // check if the button is pressed
if (lightMode == 0) { // is the light off?
lightMode = 1; // turn light on!
digitalWrite(led1Pin, HIGH);
}
else {
lightMode = 0; // turn light off!
digitalWrite(led1Pin, LOW);
}
}
}
buttonState = val; // save the new state in our variable
}
}

Con este esquema:

Si quieres màs información puedes seguir este tutorial:

http://www.ladyada.net/learn/arduino/lesson5.html

muchas gracias...ya me parecia que el codigo estaba mal... he probado el tuyo y me va perfectamente ,de nuevo muchas gracias por resolver mis dudas , un saludo :wink: :slight_smile:

En realidad no es mi código. Es de Limor Fried, irónicamente ella escribió y modificó ambos códigos.