Bandwidth Meter

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
jonsm
 
Posts: 4
Joined: Thu Oct 17, 2013 10:36 am

Bandwidth Meter

Post by jonsm »

I have an Arduino Uno and I'm using the NeoPixel strip. I'm creating a bandwidth meter. What I'm having issues with is calculating what color to use. What I want to do it have the strip gradient from green->yellow->red. To determine how many LEDs to fill I just calculate the percent of bandwidth then calculate the percentage of how many LEDs are in the strip. For example if I have a max bandwidth of 1Gbit/s and I am using 250Mbit/s that would be about 15 leds lit and mostly green The thing I'm having issues with is calculating the color. Any help would be great.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Bandwidth Meter

Post by adafruit_support_rick »

You can't simply have a test to say that if the bandwidth is <= some number, then use green, otherwise use red?

User avatar
jonsm
 
Posts: 4
Joined: Thu Oct 17, 2013 10:36 am

Re: Bandwidth Meter

Post by jonsm »

Sorry I'll be a little more clear. What my question is how can I have a gradient of green at one end yellow in the middle and red at the end. Like if my bandwidth was 250Mbits it would be mostly green and maybe a little yellow, but If the bandwidth was 750Mbits the strip would be green at the beginning and gradient to yellow and maybe a little red at the end. Hopefully that makes sense.

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Bandwidth Meter

Post by adafruit_support_rick »

A typical bargraph display would simply have, say, 15 green pixels, 5 yellow pixels, and 5 red pixels. You could do that with three for loops. Assume the variable peak is the highest pixel number you want to illuminate. Peak is directly related to your bandwidth measurement. So you could do

Code: Select all

  for (pixel = 0; pixel <= min(peak, 15); pixel++) {
    strip.setPixelColor(pixel, strip.Color(0, 255, 0));  // Green
  }
  for (pixel = 16; pixel <= min(peak, 20); pixel++) {
    strip.setPixelColor(pixel, strip.Color(255, 255, 0));  // Yellow
  }
  for (pixel = 21; pixel <= min(peak, 25); pixel++) {
    strip.setPixelColor(pixel, strip.Color(255, 0, 0));  // Red
  }

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

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