Presentation is loading. Please wait.

Presentation is loading. Please wait.

// A // --- // F| G |B // --- // E| |C // ---.Dp // D // My LED Functions Scott Nichols.

Similar presentations


Presentation on theme: "// A // --- // F| G |B // --- // E| |C // ---.Dp // D // My LED Functions Scott Nichols."— Presentation transcript:

1 // A // --- // F| G |B // --- // E| |C // ---.Dp // D // My LED Functions Scott Nichols

2 // a zero means LED ON DpGFE DCBA // #define NUM1 0xF9 //0b1111 1001 #define NUM2 0xA4 //0b1010 0100 #define NUM3 0xB0 //0b1011 0000 #define NUM4 0x99 //0b1001 1001 #define NUM5 0x92 //0b1001 0010 #define NUM6 0x82 //0b1000 0010 #define NUM7 0xF8 //0b1111 1000 #define NUM8 0x80 //0b1000 0000 #define NUM9 0x90 //0b1001 0000 #define NUM0 0xC0 //0b1100 0000 #define NUMA 0x88 //0b1000 1000 #define NUMB 0x83 //0b1000 0011 #define NUMC 0xA7 //0b1010 0111 #define NUMD 0xA1 //0b1010 0001 #define NUME 0x86 //0b1000 0110 #define NUMF 0x8E //0b1000 1110 #define BLANK 0xFF #define NUMERROR 0x86 //0b1000 0110

3 void showNumber(unsigned long outputNum) { switch(outputNum) { case 0: PORTA = NUM0; break; case 1: PORTA = NUM1; break;... case 10: PORTA = NUMA; break;... case BLANK: PORTA = BLANK; break; default: PORTA = NUMERROR; }

4 // Defines for the segments // #define PORTB_LED_SEG 0x0F #define LED_SEG_3 0xE0 //0b1110 #define LED_SEG_2 0xD0 //0b1101 #define LED_SEG_1 0xB0 //0b1011 #define LED_SEG_0 0x70 //0b0111 #define LED_SEG_D 0xF0 //0b1111

5 void showLED(unsigned char ledshow) { unsigned char pB; pB = PORTB; showNumber(BLANK); // ghosting if not here switch (ledshow) { case 3: PORTB = (pB & PORTB_LED_SEG) | LED_SEG_3; break; case 2: PORTB = (pB & PORTB_LED_SEG) | LED_SEG_2; break; case 1: PORTB = (pB & PORTB_LED_SEG) | LED_SEG_1; break; case 0: PORTB = (pB & PORTB_LED_SEG) | LED_SEG_0; break; default: PORTB = (pB & PORTB_LED_SEG) | LED_SEG_D; }


Download ppt "// A // --- // F| G |B // --- // E| |C // ---.Dp // D // My LED Functions Scott Nichols."

Similar presentations


Ads by Google