//declaramos los pins de los LEDs
int seg7[7] = {2, 3, 4, 5, 6, 7, 8};//a, b, c, d ,e ,f, g
int numeros [10][7] =
{
{1, 1, 1, 1, 1, 1, 0}, //0
{0, 1, 1, 0, 0, 0, 0}, //1
{1, 1, 0, 1, 1, 0, 1}, //2
{1, 1, 1, 1, 0, 0, 1}, //3
{0, 1, 1, 0, 0, 1, 1}, //4
{1, 0, 1, 1, 0, 1, 1}, //5
{1, 0, 1, 1, 1, 1, 1}, //6
{1, 1, 1, 0, 0, 0, 0}, //7
{1, 1, 1, 1, 1, 1, 1}, //8
{1, 1, 1, 0, 0, 1, 1}, //9
};
const int potPin=A1;
void setup()
{
// put your setup code here, to run once:
for(int i=0; i<7; i++)
{
pinMode(seg7[i], OUTPUT);
}
}
void loop()
{
// put your main code here, to run repeatedly:
int potenciometro = analogRead(potPin);
int numero = map(potenciometro, 0, 1023, 0, 9);
esteNumero(numero);
delay(100);
}
void esteNumero(int y)
{
for(int x=0; x<7; x++)
{
digitalWrite(seg7[x], numeros[y][x]);
}
}