Resistor for 3-digit 7-segment LCD

Please bear with me on this one...I know what I want to achieve but as usual don't know how to achieve it.

I want to make a simple light box powered by my Arduino Mega. I say simple, but as usual...not really.

The light box will use 144 WS2812 LEDs (they are the "strip" ones so already have the "per LED" capacitors on the strip.

I want to build a control panel for the light box that will give full control over the RGB values of the LEDs, both en-masse and individually. This will be achieved by a potentiometer knob for each channel, plus an LCD display for each channel, allowing each of RGB to be set anywhere from 0 to 255 and displaying accordingly on the LED displays.

Inidividual LED selection will be achieved by a numeric keypad, pressing "0" will toggle between all LEDS or a single LED (for the potentiometer controls) and the 2,4,6 and 8 keys will allow me to "move" the individual LED on the grid.

I have common anode LED displays and I'm aware they need current limiting resistors...but I don't want to get the values wrong.

The data sheet for my displays is here;

CA 7 segment 3 digit LED data sheet

I'll be using a 5v power supply. The display says it takes 100mA and has 5v "reverse voltage"...is this the same as the voltage drop? In which case (5-5)/100 = zero? Does this display really not require a resistor if I'm using a 5v source?

Also - is the 5v per segment, or is this for the whole display?

Thanks all for the help.

The display says it takes 100mA

The 100mA is the maximum pulsed current (10ms out of 1 sec) that a segment can withstand without permanent damage, not the operating current. The absolute maximum forward current per segment is 20mA so you should choose resistors that will limit the segment current to less than 20mA.

Reverse voltage is how much voltage a segment can withstand when reverse biased (hooked up backwards). It has nothing to do with choosing a proper resistors.

How many displays are you going to use? How are they to be interfaced? Normally you would need a resistor for each segment (or digit depending on the driver (multiplexing) method).

Thanks gf...I was just going to come back saying I'd found the advice on the resistor (one per digit).

Also due to my newness hadn't realised just how many pins we're talking about to run these darned things...just read about multiplexing so yeah, new stuff to learn.

Ideally, three displays, because that way is the easiest (and prettiest - I have Red, Green and Blue displays so since they'll be controlling the red, green and blue inputs to the LEDs - seems logical!).

I've already figured out how to convert the potentiometer output on the A0 pin from 0 to 255 (easy...divide by 2.5!) and I've got one of the displays working using the sevenseg library.

However....having another problem in that I seem to have "locked up" my Mega somehow...I can't write to it any more. I've seen a few people have had the same problem, though not recently. I can read the board info from the Com port, but my TX light on the board is on constantly and I get a "avrdude: ser_open(): can't open device "\.\COM4": Access is denied." error when trying to upload...it also won't allow me to open Serial Monitor any more - says the board is unavailable. I've tried changing com ports in device manager with no success.

Any clues as to how to rescue the board?

Board rescued...not sure what I did exactly, but I think powerign it down and powering it back up while holding reset...it seems to be holding up...I've added a "delay(1000)" after my Serial.begin(9600) statement and so far it's staying responsive.

The LCD display has a pronounced "flicker"...any way to stop/reduce it? I've tried adding a delay or a millis() based time pause but it seems to make it update in a "mexican wave" style...I also tried using the screen refresh command only when the potentiomete value changed...but that sends it black when the number is constant.

Why not save yourself all the problems, number and value of series resistors, dealing with all those pins, multiplexing without flickering etc. by using a proper led display driver chip? It will solve all those problems and let you focus on your real project. I already suspect that your locking-up problems are due to overheating the Arduino by driving those displays incorrectly.

The two most common chips used in Arduino circuits are max7219 and ht16k33. The max chip is most common, but can only drive 8 digits, so you would need 2 chips. Because the green and blue displays have the same forward voltage, I would put them on one chip and the red display on the other chip. The ht chip can drive 16 digits.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you post a copy of your code please?

Thanks.. Tom... :slight_smile:

TomGeorge:
Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Can you post a copy of your code please?

Thanks.. Tom... :slight_smile:

I'm not even there yet Tom...I've got ONE of the displays to work with a potentiometer. Knowing me I've probably connected every darned thing wrong and missed out every component it's suppposed to have.

but...I turn the knob and the lights come on and the LED goes from 0 to 244...which tells even a noob like me that I don't have enough power to run everything. The fact that all the damn lights go out if I leave it on 244 for more than about ten seconds...yeah, just reinforces it.

I will admit as far as arduino and electronics goes I am a monkey with car keys...just 'cos i own it doesn't mean I should be driving it...

I have a bit of code, I'll post it, but you lot will doubtless abuse me for usign the libraries. I SUCK at diagrams and mine is probably wrong in every respect. It will be about as much use as "some wires go in here, and the screen is here"...but hey...give me a few and I'll try...

Code...drawing will take me longer due to disability. Not looking for sympathy, just understanding.

//LightBox
//Sketch to control a lightbox consisting of 144 WS2812B LEDs
//arranged in a 12x12 grid
//external controls will allow full control of RGB output
//for the whole set of LEDs and for a selected individual LED.
//by Nigel Coxon 13/4/2018

#include "SevSeg.h"
#include <Adafruit_NeoPixel.h>
#define N_LEDS           144   //LEDS in grid
#define PIN               8    //output pin for LED data
long lastread = millis();

SevSeg sevseg;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

int potPin = A0;    // select the input pin for the potentiometer (currentyl only using one)
int Aval1 = 0;      // variable to store the value coming from the sensor
int Rval = 0;       // Red - only value currently actively controllable
int Gval = 0;       // Green
int Bval = 0;       // Blue

void setup() {
  strip.setBrightness(255);
  strip.begin();

  int pixelarray[12][12] = {
    {   0,   0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,},
    {  22,  21,  20,  19,  18,  17,  16,  15,  14,  13,  12,  11,},
    {  23,  24,  25,  26,  27,  28,  29,  30,  31,  32,  33,  34,},
    {  46,  45,  44,  43,  42,  41,  40,  39,  38,  37,  36,  35,},
    {  47,  48,  49,  50,  51,  52,  53,  54,  55,  56,  57,  58,},
    {  70,  69,  68,  67,  66,  65,  64,  63,  62,  61,  60,  59,},
    {  71,  72,  73,  74,  75,  76,  77,  78,  79,  80,  81,  82,},
    {  94,  93,  92,  91,  90,  89,  88,  87,  86,  85,  84,  83,},
    {  95,  96,  97,  98,  99, 100, 101, 102, 103, 104, 105, 106,},
    { 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107,},
    { 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,},
    { 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131,}
  };

  // The pixelarray is used in the form "pixelarray[x][y]" to return the sequential pixel number in the strip.
  // The double zero at the start is intentional as I have one damaged pixel due to a soldering mistake.

  int lightpitch = 1; //sometimes I use a grid of 30-pitch LEDS. Changing lightpitch to 2 simulates this (lights every other LED)
  byte numDigits = 3; //for the displays
  byte digitPins[] = {10, 11, 12}; //for thie digits on the display
  byte segmentPins[] = {22, 26, 34, 30, 28, 24, 36, 32}; //pins used for each segment (a,b,c,d,e,f,g, dp)

  bool resistorsOnSegments = true; //I don't know what this does
  bool updateWithDelaysIn = true; //I don't know what this does
  byte hardwareConfig = COMMON_ANODE; //Yay, I know I have CA displays!
  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
  sevseg.setBrightness(90);

  Serial.begin(9600);
  delay(1000);
}

void loop() {
  int p = 0;

  // intialise pixels woth current values
  for (p = 0; p < N_LEDS; p++) {
    strip.setPixelColor(p, Rval, Gval, Bval);
  }
  strip.show();

  // read the value from the sensor
  Aval1 = analogRead(potPin);

  //convert from 0-1023 (5v) to 0-255
  Rval = Aval1 * 0.25;

  //update pixels with new value
  for (p = 0; p < N_LEDS; p++) {
    strip.setPixelColor(p, Rval, Gval, Bval);
  }
  strip.show();

  //update the LCD display with the new value
  sevseg.setNumber(Rval, 0);
  sevseg.refreshDisplay();
  Serial.print("Value;");
  Serial.println(Aval1);

}

If you think the code is bad wait until yo usee the connection diagram...

Downloaded fritzing...fallen at hurdle one...no component icon for an Arduino Mega? I've updated the parts list...is this normal?

Edit..also at second hurdle...no three -digit LED displays...only single or four...both options give me wrong number of pins...

D'oh...found the Mega...in my defence, icon looks nothing like one!

Image attached. There's a gaping hole where the three-digit 7-segment LED should be, but the connectors are in the correct places;

1 - e
2 - d
3 - dp
4 - c
5 - g
6 - no pin
7 - Digit 1
8 - a
9 - f
10 - Digit 2
11 - Digit 3
12 - b

I don't mind hearing all the things that are wrong with it...as long as it's accompanied by how to put it right...with instructions that a monkey with a soldering iron could follow...

PaulRB:
Why not save yourself all the problems...?

Because I didn't know that thing existed. Two chips sounds like hard work, so the HT it is. I've no idea how it works of course...but then yesterday I didn't know how the 7-segment 3 digit dispaly worked either.

So questions;

Is there a different version of the driver chip for common anode/common cathode displays?

er...and actually that's it for now.

Except...my circuit as posted...if I don't copnnect the 144 WS2812B LEDs, the potentiometer goes 0 to 1023, which I divide by 2.5 to convert to 0-255.

With the LEDs connected, it only goes 0-244. I assume that the Mega is not providing enough power to run everything...

...so I took the +5v and GND line fro the WS2812bs and powered them, from my bench power supply.

Given the sketch only gives the option of being red (from 0 to 255)....they did a very god disco ball impression...lots of multicoloured flashing. There's obviously some reason why what I did is a really bad idea.

Anyone care to enlighten me?

GreyArea:
Code...drawing will take me longer due to disability. Not looking for sympathy, just understanding.
If you think the code is bad wait until yo usee the connection diagram...

No worries mate, as long as we know the situation,
@GreyArea Circuit;


That is a good Fritzy diagram, keeping crossed wires at right-angles and well separated helps to keep it clean.
Because you are multiplexing the display with software it may get a little flickery when you get the software to do extra stuff, but it will remain to be seen how much.
Tom....; :slight_smile:

Hi,
Have you got the electro cap as close as possible to the power leads of the LED strip?

Tom... :slight_smile:

The next two holes. I only stuck it on the end in the diagram because it's a big fat icon for some reason...

Ordered the board that PaulRB recommended...especially as it said it can also drive a keypad...

Not as neat in real life unfortunately...

Hi.
@GreyArea picture;


Are you using the red and black leads in the top left hand corner of the picture plugged into the red and blue power rails?
If so, the break in the red and blue bus lines down the side of the protoboard means it is not connected to the rest of your circuit.

Tom... :slight_smile:

Those two wiires come from my desktop power supply currently set to 4.5v.

As to "Am I using it", answer is best given in stages...

Stage 1;

There were links between the power rails in the centre and I was just using the power from the Arduino. When connected like this the LED display only reads 244 at maximum (it reads 255 with the box of WS2812 LEDs disconnected) and if left at 244 for more than about 10 seconds, the Arduino would power down/disconnect. So...

Stage 2;

With the connectors still in place between the two power rails, I connected the power from my desktop suipply (4.5v). LEDs flash like crazy and LED display very unstable. realised I had two voltages on same line, probably not wise.

Stage 3;

removed links between power rails so power to WS2812s now entirely separate from power to Arduino and potentiometer etc. LEDs still flashing like disco ball.

Stage 4; (this morning!)
reconnected links, supplied ALL power from desktop supply, using VIn on arduino instead of usb. seems to work...display hits 255 and ws2812bs are on steady and the board isn't shutting down.

Did I finally get where I'm supposed to be?

Hi,
In stage 3 you need to connect the gnd of both arduino and LED supply.

The supplies will still be independent but the gnd reference will be the same, very important for the control signal to the LED strip.

Tom... :slight_smile:

Thank you...I’ve seen that mentioned before, keep forgetting...

Video here...

Ignore the random led at the right of my breadboard...it’s just my way of reminding me that the power is on.

HT16K33...I’ve searched another thread where it says to use common cathode displays. Mine are CA. Not a huge thing to get new ones, but could someone confirm that I do actually need to?