Así que a todas las personas que no entienden de arreglos de discos de aquí es otra forma de hacer un segmento de 4 dígitos 7 Mostrar trabajo.
aPin int = 2; // A
bPin int = 3; // ________
cPin int = 4; // | |
Trabajo de int = 5; // F | | B
ePin int = 6; // | G |
fPin int = 7; // |________|
gPin int = 8; // | |
int GND1 = 9; // | |
int GND2 = 10; // E | | C
int GND3 = 11; // |________|
int GND4 = 12; //
int num; // D
dig1 int = 0;
dig2 int = 0;
dig3 int = 0;
dig4 int = 0;
int tiempo = 4;
void setup()
{
pinMode (aPin, salida);
pinMode (bPin, salida);
pinMode (cPin, salida);
pinMode (trabajo, salida);
pinMode (ePin, salida);
pinMode (fPin, salida);
pinMode (gPin, salida);
pinMode (GND1, salida);
pinMode (GND2, salida);
pinMode (GND3, salida);
pinMode (GND4, salida);
Serial.Begin(9600);
}
void loop()
{
digitalWrite (GND1, alto);
digitalWrite (GND2, alto);
digitalWrite (GND3, alto);
digitalWrite (GND4, alto);
Si (Serial.available() > 0)
{
Num = Serial.parseInt();
Serial.println(NUM);
dig1 = num / 1000;
Num = num - (dig1 * 1000);
dig2 = num / 100;
Num = num - (dig2 * 100);
dig3 = num / 10;
dig4 = num - (dig3 * 10);
}
digitalWrite (GND4, bajo); dígitos 4
pickNumber(dig4);
Delay(DTime);
digitalWrite (GND4, alto);
digitalWrite (GND3, LOW); dígitos 3
pickNumber(dig3);
Delay(DTime);
digitalWrite (GND3, alto);
digitalWrite (GND2, LOW); dígito 2
pickNumber(dig2);
Delay(DTime);
digitalWrite (GND2, alto);
digitalWrite (GND1, LOW); dígito 1
pickNumber(dig1);
Delay(DTime);
digitalWrite (GND1, alto);
}
void pickNumber(int x) {}
{Switch(x)}
caso 1: one(); rotura;
caso 2: two(); rotura;
caso 3: three(); rotura;
caso 4: four(); rotura;
caso 5: five(); rotura;
caso 6: six(); rotura;
caso 7: seven(); rotura;
caso 8: eight(); rotura;
caso 9: nine(); rotura;
default: zero(); rotura;
}
}
void clearLEDs()
{
digitalWrite (2, bajo); A
digitalWrite (3, bajo); B
digitalWrite (4, bajo); C
digitalWrite (5, bajo); D
digitalWrite (6, bajo); E
digitalWrite (7, bajo); F
digitalWrite (8, bajo); G
}
void one()
{
digitalWrite (aPin, LOW);
digitalWrite (bPin, HIGH);
digitalWrite (cPin, HIGH);
digitalWrite (trabajo, LOW);
digitalWrite (ePin, LOW);
digitalWrite (fPin, LOW);
digitalWrite (gPin, LOW);
}
void two()
{
digitalWrite (aPin, HIGH);
digitalWrite (bPin, HIGH);
digitalWrite (cPin, LOW);
digitalWrite (trabajo, HIGH);
digitalWrite (ePin, HIGH);
digitalWrite (fPin, LOW);
digitalWrite (gPin, HIGH);
}
void three()
{
digitalWrite (aPin, HIGH);
digitalWrite (bPin, HIGH);
digitalWrite (cPin, HIGH);
digitalWrite (trabajo, HIGH);
digitalWrite (ePin, LOW);
digitalWrite (fPin, LOW);
digitalWrite (gPin, HIGH);
}
void four()
{
digitalWrite (aPin, LOW);
digitalWrite (bPin, HIGH);
digitalWrite (cPin, HIGH);
digitalWrite (trabajo, LOW);
digitalWrite (ePin, LOW);
digitalWrite (fPin, HIGH);
digitalWrite (gPin, HIGH);
}
void five()
{
digitalWrite (aPin, HIGH);
digitalWrite (bPin, LOW);
digitalWrite (cPin, HIGH);
digitalWrite (trabajo, HIGH);
digitalWrite (ePin, LOW);
digitalWrite (fPin, HIGH);
digitalWrite (gPin, HIGH);
}
void six()
{
digitalWrite (aPin, HIGH);
digitalWrite (bPin, LOW);
digitalWrite (cPin, HIGH);
digitalWrite (trabajo, HIGH);
digitalWrite (ePin, HIGH);
digitalWrite (fPin, HIGH);
digitalWrite (gPin, HIGH);
}
void seven()
{
digitalWrite (aPin, HIGH);
digitalWrite (bPin, HIGH);
digitalWrite (cPin, HIGH);
digitalWrite (trabajo, LOW);
digitalWrite (ePin, LOW);
digitalWrite (fPin, LOW);
digitalWrite (gPin, LOW);
}
void eight()
{
digitalWrite (aPin, HIGH);
digitalWrite (bPin, HIGH);
digitalWrite (cPin, HIGH);
digitalWrite (trabajo, HIGH);
digitalWrite (ePin, HIGH);
digitalWrite (fPin, HIGH);
digitalWrite (gPin, HIGH);
}
void nine()
{
digitalWrite (aPin, HIGH);
digitalWrite (bPin, HIGH);
digitalWrite (cPin, HIGH);
digitalWrite (trabajo, HIGH);
digitalWrite (ePin, LOW);
digitalWrite (fPin, HIGH);
digitalWrite (gPin, HIGH);
}
void zero()
{
digitalWrite (aPin, HIGH);
digitalWrite (bPin, HIGH);
digitalWrite (cPin, HIGH);
digitalWrite (trabajo, HIGH);
digitalWrite (ePin, HIGH);
digitalWrite (fPin, HIGH);
digitalWrite (gPin, LOW);
}