Go Down

Topic: [Risolto] 2 button 2 Led (Read 771 times) previous topic - next topic

Datman

#15
Jan 01, 2019, 08:21 pm Last Edit: Jan 01, 2019, 10:14 pm by Datman
Fai così:
Code: [Select]
byte a=0;
unsigned long t1=0;

void setup()
{
digitalWrite(12,HIGH);
digitalWrite(11,LOW);
}

void loop()
{
if(millis()-t1>2*3600*1000 && a==0)
  {
  a=1; t1=millis();
  digitalWrite(11,HIGH);
  digitalWrite(12,LOW);
  }

if(millis()-t1>2*3600*1000 && a==1)
  {
  a=1; t1=millis();
  digitalWrite(12,HIGH);
  digitalWrite(11,LOW);
  }
}
Come to ho detto prima, ti servono dei microswitch di fine corsa a deviatore, non semplici interruttori, e devono sopportare la corrente assorbita dal motore.
Hi,I'm Gianluca from Roma.I play&work with electronics since I was16(1984).
After 25yrs of maintenance on cameras&video mixers,since 2013myJob is HDTVstudios design.
Since Jan2015 IPlayWith Arduino:bit.ly/2F3LPWP
Thanks 4 a Karma if U like my answer

ouassour

Code: [Select]
byte a=0;
unsigned long t1=0;
const int rely1 = 6;     // the number of the pushbutton pin
const int rely2 = 7;     // the number of the pushbutton pin
int relystat1 = 0;
int relystat2 = 0;



void setup()
{
pinMode(rely1, INPUT);
pinMode(rely2, INPUT);


digitalWrite(12,HIGH);
digitalWrite(11,LOW);


}

void loop()
{
  relystat1 = digitalRead(rely1);
  relystat2 = digitalRead(rely2);
if(millis()-t1>2*3600*1000 && a==0 && (relystat1=LOW))
  {
  a=1; t1= millis();
  digitalWrite(11,HIGH);
  digitalWrite(12,LOW);
  }

if(millis()-t1>2*3600*1000 && a==1 && (relystat2=LOW) )
  {
  a=1; t1= millis();
  digitalWrite(12,HIGH);
  digitalWrite(11,LOW);
  }
}

 
ho dato una modifica mettendo 2 rely separati al arrivo del motore alla posizione esci della if e rimane fermo dici che va bene codice

Datman

#17
Jan 01, 2019, 09:25 pm Last Edit: Jan 01, 2019, 10:12 pm by Datman
??? Devi mettere un relè (relay in inglese) sull'11 (o sul 6) e uno sul 12 (o sul 7), senza modificare il programma (salvo usare il 6 e il 7 o errori).
Hi,I'm Gianluca from Roma.I play&work with electronics since I was16(1984).
After 25yrs of maintenance on cameras&video mixers,since 2013myJob is HDTVstudios design.
Since Jan2015 IPlayWith Arduino:bit.ly/2F3LPWP
Thanks 4 a Karma if U like my answer

ouassour


Datman

Hi,I'm Gianluca from Roma.I play&work with electronics since I was16(1984).
After 25yrs of maintenance on cameras&video mixers,since 2013myJob is HDTVstudios design.
Since Jan2015 IPlayWith Arduino:bit.ly/2F3LPWP
Thanks 4 a Karma if U like my answer

Go Up