gabbyshimoni icon

write0-9to7seg

gabbyshimoni | PRO | 01/29/19 05:34:20 PM UTC | 0 ⭐ | 585 👁️ | Never ⏰ | []
C++ |

1.17 KB

|

None

|

0 👍

/

0 👎

/*
 * 29.01.2019
 * Written by: Gabby Shimoni
 * Description:
 * This program write the digits 0-9 to 7 segment
 */
 
int num_array[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
                                       
//function header
void Num_Write(int);
 
void setup() 
{ 
  // set pin modes
 for(int k=2;k<9;k++)  pinMode(k, OUTPUT);   
}
 
void loop() 
{
  //counter loop
  for (int counter = 0; counter > 10; counter++) 
  {
   delay(1000);
   Num_Write(counter); 
  }
  delay(3000);
}
 
// this functions writes values to the sev seg pins  
void Num_Write(int number) 
{
  int pin= 2;
  for (int j=0; j < 7; j++) {
   digitalWrite(pin, num_array[number][j]);
   pin++;
  }
}

Comments