1 / 5

// A // --- // F| G |B // --- // E| |C // ---.Dp // D //

My LED Functions. Scott Nichols. // A // --- // F| G |B // --- // E| |C // ---.Dp // D //. // 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

melita
Download Presentation

// A // --- // F| G |B // --- // E| |C // ---.Dp // D //

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. // a zero means LED ON DpGFE DCBA // #defineNUM1 0xF9//0b1111 1001 #defineNUM2 0xA4//0b1010 0100 #defineNUM3 0xB0//0b1011 0000 #defineNUM4 0x99//0b1001 1001 #defineNUM5 0x92//0b1001 0010 #defineNUM6 0x82//0b1000 0010 #defineNUM7 0xF8//0b1111 1000 #defineNUM8 0x80//0b1000 0000 #defineNUM9 0x90//0b1001 0000 #defineNUM0 0xC0//0b1100 0000 #defineNUMA 0x88//0b1000 1000 #defineNUMB 0x83//0b1000 0011 #defineNUMC 0xA7//0b1010 0111 #defineNUMD 0xA1//0b1010 0001 #defineNUME 0x86//0b1000 0110 #defineNUMF 0x8E//0b1000 1110 #defineBLANK 0xFF #defineNUMERROR 0x86//0b1000 0110

  3. voidshowNumber(unsigned long outputNum) { switch(outputNum) { case0: PORTA=NUM0; break; case1: PORTA=NUM1; break; ... case10: PORTA=NUMA; break; ... caseBLANK: PORTA=BLANK; break; default: PORTA=NUMERROR; } }

  4. // Defines for the segments // #definePORTB_LED_SEG 0x0F #defineLED_SEG_3 0xE0//0b1110 #defineLED_SEG_2 0xD0//0b1101 #defineLED_SEG_1 0xB0//0b1011 #defineLED_SEG_0 0x70//0b0111 #defineLED_SEG_D 0xF0//0b1111

  5. voidshowLED(unsignedchar 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; } }

More Related