Bi-Color 24 Bargraph multiple led's

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
SrGadget
 
Posts: 10
Joined: Wed Aug 31, 2022 11:55 am

Bi-Color 24 Bargraph multiple led's

Post by SrGadget »

Question: I recently purchased a Bi-Color 24 Bargraph from you and using it just fine with Arduino nano board. the question I have in the code " bar.setBar(12, LED_GREEN);" if I want easily set say led 0 through and including 11 what would the syntax be ? I have look in your doc's and the forum to no avail I have tried a few thing also with no luck. Any thoughts ideas or guidance would be greatly appreciated....

User avatar
dastels
 
Posts: 15654
Joined: Tue Oct 20, 2015 3:22 pm

Re: Bi-Color 24 Bargraph multiple led's

Post by dastels »

Maybe:

Code: Select all

void draw_bar(uint8_t first, uint8_t last, uint8_t color) {
  for (int led_number = first; led_number <= last; led_number++) {
    bar.setBar(led_number, color);
  }
}
Then call it:

Code: Select all

draw_bar(0, 11, LED_GREEN);
Dave

User avatar
SrGadget
 
Posts: 10
Joined: Wed Aug 31, 2022 11:55 am

Re: Bi-Color 24 Bargraph multiple led's

Post by SrGadget »

Many thanks Dave I need to read up on using "uint8_t" your a gentleman and a scholar .... Have a good weekend.

User avatar
dastels
 
Posts: 15654
Joined: Tue Oct 20, 2015 3:22 pm

Re: Bi-Color 24 Bargraph multiple led's

Post by dastels »

uint8_t is just a standard type alias for unsigned 8 bit integers. I.e. a byte.

Dave

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”