Go Down

Topic: 7segment displays with max7219 chip counting (Read 802 times) previous topic - next topic

adknotty

hello all,

i have just started using arduino from various other C based controllers and have a uni project that im trying to sort out asap.  i have 2 7segment displays mutiplexed up and working fine, but im trying to work out how i can have a potentiometer connected to control the digits that have been displayed.  The hardwear works fine its just my coding abilities that i am having trouble with. In fact i have no idea how to start. 
any help would be gratefully appreciated

cheers
   
adknott

Justin

I'd start by writing a function

// set/unset segments of display identified by display_id
void seven_seg_contol(int display_id, uint8_t bits){
    for(uint8_t i = 0; i < 8; i++){
    if(1 && bits >> i){
        // light up the ith segment of display_id
    }
    else{
        // unlight the ith segment of display_id
    }
}

Then define constants for each digit.
const uint8_t ONE = 0b00010001;  // just for instance I don't really know which bits to be on or off
const uint8_t TWO = 0b01111001;  // just for instance I don't really know which bits to be on or off
...

Then write a higher level function display

void seven_seg_display(uint8_t two_digit_num){
   // ones digit
    switch(two_digit_num % 10){
    case 1:
        seven_set_control(ONES_DIGIT, ONE);
        break;
    ...
    }
   // tens digit
    switch(two_digit_num / 10){
    case 1:
        seven_set_control(TENS_DIGIT, ONE);
        break;
    ...
    }
}

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy