[RISOLTO] Convertire in millis()

Ciao a tutti, mi potreste aiutare a tradurre questo codice in millis()...

Grazie

#define RELE1   5           
#define RELE2   2

void setup(){
  pinMode(RELE1, OUTPUT);   
  pinMode(RELE2, OUTPUT);
}
void loop(){

  digitalWrite(RELE1, 0);
  delay(1000);
  digitalWrite(RELE1, 1);

  digitalWrite(RELE2, 0);
  delay(1500); 
  digitalWrite(RELE2, 1);   
}

Lo schitto in questo modo ma non funziona xkè?

const int rele1 =  5;  
const int rele2 =  2;

int releState1 = LOW;
int releState2 = LOW;

unsigned long previousMillis1 = 0;    
unsigned long previousMillis2 = 0;  

const long interval1 = 500;  
const long interval2 = 1500; 

void setup() {  
  pinMode(rele1, OUTPUT);
  pinMode(rele1, OUTPUT);    
}

void loop() {
  
  unsigned long currentMillis = millis();

  if(currentMillis - previousMillis1 >= interval1) {    
    previousMillis1 = currentMillis;   
    
    if (releState1 == LOW)
      releState1 = HIGH;
    else
      releState1 = LOW;

    
    digitalWrite(rele1, releState1);
  }
  
  if(currentMillis - previousMillis2 >= interval2) {    
    previousMillis2 = currentMillis;   
    
    if (releState2 == LOW)
      releState2 = HIGH;
    else
      releState2 = LOW;

    
    digitalWrite(rele2, releState2);
  }
}

ciao, io ci sono riuscito con questo esempio.

const int buttonPin1 = 8;     // the number of the pushbutton pin
const int buttonPin2 = 9;
const int ledPin1 =  4;  // the number of the LED pin
const int ledPin2 =  5;
unsigned long off_time1;
unsigned long off_time2;

boolean ledState1=false;
boolean ledState2=false;

int buttonState1 = 0;    // variable for reading the pushbutton status
int buttonState2 = 0;

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);  
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin1, INPUT);
  pinMode(buttonPin2, INPUT);  
  digitalWrite(ledPin1, LOW); 
  digitalWrite(ledPin2, LOW);

}

void loop(){

if ((ledState1) && (millis()>=off_time1)) /* is it on and is it later or equal to off_time */
{
    digitalWrite(ledPin1,HIGH);
    ledState1 = false;
}
else if (!ledState1) /* is it off? */
{
    buttonState1 = digitalRead(buttonPin1);
    if(buttonState1 == LOW)
    {
        digitalWrite(ledPin1, HIGH);
        ledState1 = true;
        off_time1 = millis() + 20000;
    }
}


if (buttonState1==HIGH && buttonState2==HIGH)
{
  digitalWrite(ledPin1,LOW);
  digitalWrite(ledPin2,LOW);
 // off_time = millis() + 0;
}

if ((ledState2) && (millis()>=off_time2)) /* is it on and is it later or equal to off_time */
{
    digitalWrite(ledPin2,HIGH);
    ledState2 = false;
}
else if (!ledState2) /* is it off? */
{
    buttonState2 = digitalRead(buttonPin2);
    if(buttonState2 == LOW)
    {
        digitalWrite(ledPin2, HIGH);
        ledState2 = true;
        off_time2 = millis() + 20000;
    }
}

}