Hallo, ich habe folgendes Problem, ich habe mit einem Arduino Uno und einem cd4511 eine led 7 Segment-Anzeige angesteuert. Dies soll als Countdown fungieren mit einem 3min und dann 1 minutigen countdown.
Also genau heist das daß die 7 Segmentanzeige erst von 3min runter zählt und dannach von 1min runter, danach sollte es wieder bei 3 anfangen usw. Mein Code zur Zeit sieht folgender weise so aus:
// Pin matching from 4511 to Aduino
const int LedA = 5;
const int LedB = 2;
const int LedC = 3;
const int LedD = 4;
int count = 3;
int count1 = 1;
void setup()
{
// Configure the pins connected to the 4511 as outputs
pinMode(LedA, OUTPUT);
pinMode(LedB, OUTPUT);
pinMode(LedC, OUTPUT);
pinMode(LedD, OUTPUT);
}
void loop(){
min3();
min1();
}
void min3(){
Display(count); // Displays the current count value
count = count - 1;
delay(60000);
}
void min1(){
Display(count1); // Displays the current count value
count1 = count1 - 1;
delay(60000);
}
// This function outputs the supplied value to the display.
void Display(int n)
{
// Start with a range check - remember we can only display
// from 0 to 9!
if ( n > 9 )
{
n = 9;
}
if ( n < 0 )
{
n = 0;
}
// The rest from here is basic decimal to binary conversion
if ( n / 8 == 1 )
{
digitalWrite(LedD, HIGH);
}
else
{
digitalWrite(LedD, LOW);
}
n = n % 8;
if ( n / 4 == 1 )
{
digitalWrite(LedC, HIGH);
}
else
{
digitalWrite(LedC, LOW);
}
n = n % 4;
if ( n / 2 == 1 )
{
digitalWrite(LedB, HIGH);
}
else
{
digitalWrite(LedB, LOW);
}
n = n % 2;
if ( n == 1 )
{
digitalWrite(LedA, HIGH);
}
else
{
digitalWrite(LedA, LOW);
}
}
Ich weis es fehlt noch was, aber ich hänge irgendwie fest, vielleicht kann mir irgendeiner weiterhelfen.