Ik heb 2, 7 segment wordt weergegeven welke aftellen van 20 naar nul en vervolgens het piëzo-zoemer beebs voor een tijdje.
Mijn vraag is:
Ik wil een relais ingeschakeld voor 20 tweede tegelijkertijd met de 7 segment countdown.
Dus als het aftellen begint, de estafette wordt geopend en wanneer het volledige 20, 19, 18, 17, 16,15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 dan het Relais moet sluiten.
Hier is mijn code voor tot nu toe.
Als iemand me met tips of iets helpen kan, dat zou geweldig ;)
GR Mark
int pin1 = 2;
int pin2 = 3; // --6--
int pin3 = 4; // 5 | | 7
int pin4 = 5; // |--4--|
int pin5 = 6; // 1 | | 3
int pin6 = 7; // --2--
int pin7 = 8;
int gnd1 = 11; gnd1 is weergave 1 de gnd
int gnd2 = 9; gnd2 is scherm 2 de gnd
int timer = 100; Een timer, uit te voeren de for-lus 500 keer, die blijkt als 1 seconde.
int waarde; De waarde, onderdeel van de FADING weergeven
VOID Setup {}
pinMode (pin1, OUTPUT);
pinMode (pin2, OUTPUT);
pinMode (pin3, OUTPUT);
pinMode (pin4, OUTPUT); De volgende sets up van al de pinnen voor gebruik.
pinMode (pin5, OUTPUT);
pinMode (pin6, OUTPUT);
pinMode (pin7, OUTPUT);
pinMode (gnd1, OUTPUT);
pinMode (gnd2, OUTPUT);
pinMode (12, OUTPUT); Uitgang voor de herhalende pieptoon
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B1);
digitalWrite (pin4, B0);
digitalWrite (pin5, B1);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); Schrijft 20 aan de weergave.
digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 19 schrijft aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 18 schrijft naar het scherm.
digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 17 schrijft aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); Schrijft 16 aan de weergave.
digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B1);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 15 schrijft naar het scherm.
digitalWrite (pin1, B1);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B1);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); Schrijft 14 aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B0);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 13 schrijft aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B1);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 12 schrijft aan de weergave.
digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B1);
digitalWrite (pin4, B0);
digitalWrite (pin5, B1);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); Schrijft 11 aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); Schrijft 10 aan de weergave.
digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 09 schrijft aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); Schrijft 08 aan de weergave.
digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 07 schrijft aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 06 schrijft aan de weergave.
digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B1);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 05 schrijft aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B1);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 04 schrijft aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B0);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 03 schrijft aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B0);
digitalWrite (pin5, B1);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 02 schrijft aan de weergave.
digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B1);
digitalWrite (pin4, B0);
digitalWrite (pin5, B1);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); 01 schrijft aan de weergave.
digitalWrite (pin1, B1);
digitalWrite (pin2, B1);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B1);
digitalWrite (pin6, B1);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
for (int i = 0; ik digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B1);
digitalWrite (gnd2, B0);
delay(5); Schrijft 00 aan de weergave.
digitalWrite (pin1, B0);
digitalWrite (pin2, B0);
digitalWrite (pin3, B0);
digitalWrite (pin4, B1);
digitalWrite (pin5, B0);
digitalWrite (pin6, B0);
digitalWrite (pin7, B0);
digitalWrite (gnd1, B0);
digitalWrite (gnd2, B1);
delay(5);
}
}
void loop {}
digitalWrite (12, hoge); de pieptoon aangezet
delay(300); hoeveelheid tijd wachten
digitalWrite (12, laag); de pieptoon verrekening
delay(500);
digitalWrite (13, hoge); Hiermee schakelt u de TIMER EINDIGDE LED op.
voor (waarde = 0; waarde < = 255; waarde += 5) / / fade-in (van min tot max)
{
analogWrite (gnd1, waarde); Hiermee stelt u de waarde (bereik van 0 tot 255)
analogWrite (gnd2, waarde); Hiermee stelt u de waarde (bereik van 0 tot 255)
delay(10); wacht 30 milli-seconden om te zien het dimmen effect
}
voor (waarde = 255; waarde > = 0; waarde-= 5) / / uitfaden (van max naar de min)
{
analogWrite (gnd1, waarde); Hiermee stelt u de waarde (bereik van 0 tot 255)
analogWrite (gnd2, waarde); Hiermee stelt u de waarde (bereik van 0 tot 255)
delay(10);
}
}