Ayuda con temporalizador

pues eso ,la verdad que aun no le entiendo a este lenguaje y se me hace dificil.
lo que quiero es activar un rele durante 1,2 o 3 minutos y se desactive pasado el tiempo
espero me ayuden
saludos y gracias

La mejor ayuda

Lo que necesitas es un timmer sin delay... Hay muchos ejemplos en la red.

Incluso en el Ide del Arduino:

/* Blink without Delay
 
 Turns on and off a light emitting diode(LED) connected to a digital  
 pin, without using the delay() function.  This means that other code
 can run at the same time without being interrupted by the LED code.
 
 The circuit:
 * LED attached from pin 13 to ground.
 * Note: on most Arduinos, there is already an LED on the board
 that's attached to pin 13, so no hardware is needed for this example.
 
 
 created 2005
 by David A. Mellis
 modified 8 Feb 2010
 by Paul Stoffregen
 
 This example code is in the public domain.

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

// constants won't change. Used here to 
// set pin numbers:
const int ledPin =  13;      // the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED
long previousMillis = 0;        // will store last time LED was updated

// the follow variables is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 1000;           // interval at which to blink (milliseconds)

void setup() {
  // set the digital pin as output:
  pinMode(ledPin, OUTPUT);      
}

void loop()
{
  // here is where you'd put code that needs to be running all the time.

  // check to see if it's time to blink the LED; that is, if the 
  // difference between the current time and last time you blinked 
  // the LED is bigger than the interval at which you want to 
  // blink the LED.
  unsigned long currentMillis = millis();
 
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}

Opciones varias.
Debes
Definir pines para el relay
Luego en el loop debes

fijar un retardo de tiempo por 1,2,5 minutos y antes de eso definir como será la salida HIGH o LOW
Luego de transcurrido ese tiempo cambias la salida al valor opuesto
Asi como lo pides esa secuencia se repetirá hasta que el arduino deje de funcionar de modo que hay que establecer como arranca y si tiene fin la secuencia.

Pues que tal gracias por sus respuestas, la verdad que han de decir que no me esfuerzo en esto :grin: :grin: :grin:
pero se me hace un poco dificil ,trabajo 6 dias ala semana y con un bebe y esposa es un poco dificil darle prioridad a esto
bueno este codigo (lo encontre en el ide arduino, es sencillo pero lo que quiero es incorporar un retraso de 1 o 2 minutos sin usar delay

// 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 buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);      
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);     
}

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {     
    // turn LED on:    
    digitalWrite(ledPin, HIGH);  
  } 
  else {
    // turn LED off:
    digitalWrite(ledPin, LOW); 
  }
}

espero me den una pista
gracias

Ahmm... si entiendo... pero veras... tu problema es un poco mas complicado de lo que mencionas;

1.- Usar una libreria para ver que el swithc no haya dado un falso positivo, puedes usar Esta que es muy buena.

2.- Una vez leido el estado del switch... usar millis()... para contar segundos, hasta 1.3 min...

Bueno... vamos por partes... supongamos que por alguna razon no quires usar la libreria entonces tendrias que hacer algo como;

unsigned long relaydelay = 90000  //1segundo = 1000milisegundos * 60 segundos * 1.5 minutos
unsigned long switchbounce = 150 //150 milisegundos entre lecturas 
unsigned long switchbounce2 = 300 //300 milisegundos entre lecturas

unsigned long switchTimmer = 0;  // aqui anotas la "hora" cada vez que se ejecuta una funcion, para que 
unsigned long switchTimmer2= 0;
unsigned long relayTimmer   = 0;  //puedas hacerla periodicamente 

boolean relayOn = false; 
boolean pastRelayOn = false; 

void setup{
//Aqui configuras tus botones 
}


void loop(){

currentTime = millis(); 

if ( millis() - switchTimmer >= switchbounce) {  // si el tiempo actual es mayor que el lapso ente lecturas 
   buttonState1 =  digitalRead(buttonPin); }       //entonces lee el switch y almacenalo en esa variable. 
   switchTimmer = millis(); 

if ( millis() - switchTimmer2 >= switchbounce2){ // si el tiempo que ha pasado desde la ultima lectura es 
   buttonState2 = digitalRead(buttonPin); }         // mayor a 300 milisegundos lee y almacena en esa variable.
   switchTimmer2 = millis(); 

if(buttonState1 && buttonState2 == HIGH){        // si el estado 1 y 2 han sido encendidos aqui pones lo que             
   relayOn = true;                                              //quieres hacer cuando el switch se haya presionado... 

if(buttonState1 && buttonState2 == LOW   && millis() - relayTimmer >=relayTimmer){
  relayOn = false; 
  pastRelayOn = false;  

    if(relayOn != pastRealyOn || millis() - relayTimmer <= relaydelay ){
        digitalWrite(led, HIGH);         
        relayTimmer= millis();}

    else 
        relayOn  = false; 
        pastRelayOn = false;
        relayTimmer = 0;  
}

Algo asi... puede tener fallas ya que lo hice al vuelo y no intente complilarlo, pero para lo que necesitas supongo que ira bien... ahora, tengo algunas dudas sobre la lectura del switch, ya que como ves... lee el switch a los 150 milisegundos, despues a los 300ms... si ambos estados son iguales, lo declara encendido, y se supone que basta con un clik para cambiar la guara booleana... a true y false... este estado durara mientras el rele este activo... despues se apaga y espera un nuevo clik...

Bueno es mi idea, quizas haya cometido algun error por ahi... has sido dias largos ... pero espero poder ayudarte.
Si necesitas mas ayuda, debes leer algunos ejemplos de blink wotithout delay, como te mencionaba.

Como sea, esto te dara algo para comenzar.
Mucho Exito.

-Alex.

Hola

Estas usando un switch o un boton?
como sea me parece que con un delay(15) no habrá rebotes o falsos positivos, siempre y cuando lo presiones rápido, pero si necesitas que sea exacto puedes poner una variable que actué como candado dentro de un if que tenga como parámetro el estado del botón y el valor de la variable, de modo que cuando se presione el botón se cambie el estado de la variable y no pueda entrar de nuevo en el if pero cuando sea liberado el botón que se cambie el estado de la variable para que cuando sea presionado el botón de nuevo pueda entrar en el if.

En cuanto al timer para dejarlo simple podría ser que cada pulsación del botón sume un minuto y que el limite sean 3. pero igual necesitaras algo para ver cuanto tiempo falta, no crees?