KIM Uno Common Cathode LED logic 14-Jan-2015 1:34 PM
Edit FancyEdit New New Blog Upload All Recent Home Logout

void driveLEDs_CommonCathode( void )
{
  char digit = 0;

for( byte i = 0 ; i<3 ; i++ ) { for( byte j = 0 ; j<2 ; j++ ) { // get the current byte to display byte b = threeHex[i][j];

  // get the segment mask
  byte s = dig[b];

  // select just this digit
  for( int d=0 ; d<8 ; d++ ) {
    pinMode( ledSelect[d], OUTPUT ); // make sure we're output
    digitalWrite( ledSelect[d], (d==digit)?LOW:HIGH );
  }

  // now go through and turn on/off the right segments
  for( byte col =0 ; col <8 ; col++ )
  {
    pinMode( aCols[col], OUTPUT );
    digitalWrite( aCols[col], (s & (0x80>>col))? HIGH : LOW );
  }

  // wait a moment...
  delay( 2 );

  // go to the next display digit
  digit++;
}

} }