Está en la página 1de 3

/* We define the variable Leds as an array of 10 rows and 8 columns an put

o and 1 in the exact position to switch on/off the leds of SSD to represent
the ten decimal digits*/
byte Leds[10][8] =
{
{ 1,1,1,1,1,1,0,0 },

// 0

{ 0,1,1,0,0,0,0,0 },

// 1

{ 1,1,0,1,1,0,1,0 },

// 2

{ 1,1,1,1,0,0,1,0 },

// 3

{ 0,1,1,0,0,1,1,0 },

// 4

{ 1,0,1,1,0,1,1,0 },

// 5

{ 1,0,1,1,1,1,1,0 },

// 6

{ 1,1,1,0,0,0,0,0 },

// 7

{ 1,1,1,1,1,1,1,0 },

// 8

{ 1,1,1,0,0,1,1,0 }

// 9

};
int E1=0;

//we define here de digitalInput of push botton

int E2=0;
int E3=0;
int E4=0;
void setup()
{
{ for (int i= 2; i<9; i++)
pinMode(i, OUTPUT);
}
{ for (int j= 9; j<13; j++)
pinMode(j, INPUT);
}
}

void loop()
{
E1=digitalRead(9);
E2=digitalRead(10);
E3=digitalRead(11);
E4=digitalRead(12);
if (E1==0 && E2==0 &&E3==0 &&E4==0)
{
Display(0);
}
if (E1==0 && E2==0 &&E3==0 &&E4==1)
{ Display(1);
}
if (E1==0 && E2==0 &&E3==1 &&E4==0)
{ Display(2);
}
if (E1==0 && E2==0 &&E3==1 &&E4==1)
{
Display(3);
}
if (E1==0 && E2==1 &&E3==0 &&E4==0)
{ Display(4);
}
if (E1==0 && E2==1 &&E3==0 &&E4==1)
{ Display(5);
}
if (E1==0 && E2==1 &&E3==1 &&E4==0)

{
Display(6);
}
if (E1==0 && E2==1 &&E3==1 &&E4==1)
{ Display(7);
}
if (E1==1 && E2==0 &&E3==0 &&E4==0)
{ Display(8);
}
if (E1==1 && E2==0 &&E3==0 &&E4==1)
{ Display(9);
}
}

void Display(int N)
{
for (int i= 0 ; i<8 ; i++)
{ int valor = Leds[N][i] ;
int pin = i+2;
digitalWrite(pin , valor) ;
}
}

// digitalWrite(i+2 , Leds[N][i] ) ;

También podría gustarte