This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

2 digit - 7 Segment Display Example

Is there an example for using a 10 pin 2 digit 7 segment display similar the picture below?

It is common anode and actually has 10 pins (pin 2 is the DP or decimal point). I have all of the LED pins (1-4 and 5-9) hooked up to their own GPIO and the common anodes are hooked up to pins 10 and 5 through a PNP transistor. Those 2 transistors are hooked up their own GPIO pins. I need an example to multiplex the 2 displays without adding any other chips.

I did this before on Arduino using an old library I found but not sure how to do this on nRF51822.

I am using a custom board with nrf51822 chip. SDK 12.

Any help would be appreciated!

2 digit 10 pin 7 segment display 7 segment display?

Parents
  • something like this typed in without checking

    uint32_t leds_bits[2];    // two uint32s with bits set for each segment including the anode bit
    uint8_t leds_index;
    
    void called_by_app_timer_regularly()
    {
        NRF_GPIO->OUTCLR = 0x000007fe;    // clear all the pins 1-10
        NRF_GPIO->OUTSET = leds_bits[ leds_index ]; // set all the pins to the required value
        leds_index = ( 1 - leds_index ); // do the other one the next time
    }
    

    leds_bits has bit 5 clear and bit 10 set for one entry and the other way around for the other, plus the bits for the segments you want lit up set. Update that at any point, the next cycle will refresh it. Set up a repeating app_timer (lots of examples for that) to call that function regularly.

Reply
  • something like this typed in without checking

    uint32_t leds_bits[2];    // two uint32s with bits set for each segment including the anode bit
    uint8_t leds_index;
    
    void called_by_app_timer_regularly()
    {
        NRF_GPIO->OUTCLR = 0x000007fe;    // clear all the pins 1-10
        NRF_GPIO->OUTSET = leds_bits[ leds_index ]; // set all the pins to the required value
        leds_index = ( 1 - leds_index ); // do the other one the next time
    }
    

    leds_bits has bit 5 clear and bit 10 set for one entry and the other way around for the other, plus the bits for the segments you want lit up set. Update that at any point, the next cycle will refresh it. Set up a repeating app_timer (lots of examples for that) to call that function regularly.

Children
Related