PRÁCTICA Nº3:DISPLAY DE 5 SEGMENTOS CONSISTE EN MOSTRAR EN EL DISPLAY DE 7 SEGMENTOS UNA CUENTA DESDE EL 1 AL 5.
PRÁCTICA Nº3:DISPLAY DE 5 SEGMENTOS CONSISTE EN MOSTRAR EN EL DISPLAY DE 7 SEGMENTOS UNA CUENTA DESDE EL 1 AL 5.
CÓDIGO:
// PROGRAMA REALIZADO POR:JAVIER CABEZA ANDREU
//CLASE:3ºB
//FECHA:01/06/2021
//CLASE:3ºB
//FECHA:01/06/2021
#define g 1 //DEFINO MI SEGMENTO CON EL NOMBRE g Y LE ASIGNO EL PIN Nº 1
#define f 2 //DEFINO MI SEGMENTO CON EL NOMBRE f Y LE ASIGNO EL PIN Nº 2
#define a 3 //DEFINO MI SEGMENTO CON EL NOMBRE a Y LE ASIGNO EL PIN Nº 3
#define b 4 //DEFINO MI SEGMENTO CON EL NOMBRE b Y LE ASIGNO EL PIN Nº 4
#define e 5 //DEFINO MI SEGMENTO CON EL NOMBRE e Y LE ASIGNO EL PIN Nº 5
#define d 6 //DEFINO MI SEGMENTO CON EL NOMBRE d Y LE ASIGNO EL PIN Nº 6
#define c 7 //DEFINO MI SEGMENTO CON EL NOMBRE c Y LE ASIGNO EL PIN Nº 7
void setup()
{
pinMode(a, OUTPUT); //DEFINIMOS a COMO UNA SALIDA
pinMode(b, OUTPUT); //DEFINIMOS b COMO UNA SALIDA
pinMode(c, OUTPUT); //DEFINIMOS c COMO UNA SALIDA
pinMode(d, OUTPUT); //DEFINIMOS d COMO UNA SALIDA
pinMode(e, OUTPUT); //DEFINIMOS e COMO UNA SALIDA
pinMode(f, OUTPUT); //DEFINIMOS f COMO UNA SALIDA
pinMode(g, OUTPUT); //DEFINIMOS g COMO UNA SALIDA
}
void loop() {
uno(); //encendemos el void uno
delay(1000); //lo dejamos encendido 1 segundo
dos(); //encendemos el void dos
delay(1000); //lo dejamos encendido 1 segundo
tres(); //encendemos el void tres
delay(1000); //lo dejamos encendido 1 segundo
cuatro(); //encendemos el void cuatro
delay(1000); //lo dejamos encendido 1 segundo
cinco(); //encendemos el void cinco
delay(1000); //lo dejamos encendido 1 segundo
}
void uno() {
digitalWrite(b, HIGH); // encendemos el segmento b
digitalWrite(c, HIGH); // encendemos el segmento c
digitalWrite(a, LOW); //apagamos el segmento a
digitalWrite(d, LOW); //apagamos el segmento d
digitalWrite(e, LOW); //apagamos el segmento e
digitalWrite(f, LOW); //apagamos el segmento f
digitalWrite(g, LOW); //apagamos el segmento g
}
void dos() {
digitalWrite(a, HIGH); // encendemos el segmento a
digitalWrite(b, HIGH); // encendemos el segmento b
digitalWrite(g, HIGH); // encendemos el segmento g
digitalWrite(e, HIGH); // encendemos el segmento e
digitalWrite(d, HIGH); // encendemos el segmento d
digitalWrite(c, LOW); //apagamos el segmento c
digitalWrite(f, LOW); //apagamos el segmento f
}
void tres() {
digitalWrite(a, HIGH); // encendemos el segmento a
digitalWrite(b, HIGH); // encendemos el segmento b
digitalWrite(g, HIGH); // encendemos el segmento g
digitalWrite(c, HIGH); // encendemos el segmento c
digitalWrite(d, HIGH); // encendemos el segmento d
digitalWrite(f, LOW); //apagamos el segmento f
digitalWrite(e, LOW); //apagamos el segmento e
}
void cuatro() {
digitalWrite(f, HIGH); // encendemos el segmento f
digitalWrite(g, HIGH); // encendemos el segmento g
digitalWrite(b, HIGH); // encendemos el segmento b
digitalWrite(c, HIGH); // encendemos el segmento c
digitalWrite(a, LOW); //apagamos el segmento a
digitalWrite(e, LOW); //apagamos el segmento e
digitalWrite(d, LOW); //apagamos el segmento d
}
void cinco() {
digitalWrite(a, HIGH); // encendemos el segmento a
digitalWrite(f, HIGH); // encendemos el segmento f
digitalWrite(g, HIGH); // encendemos el segmento g
digitalWrite(c, HIGH); // encendemos el segmento c
digitalWrite(d, HIGH); // encendemos el segmento d
digitalWrite(b, LOW); //apagamos el segmento b
digitalWrite(e, LOW); //apagamos el segmento e
}
Comentarios
Publicar un comentario