Seven Segment Display bottom left segment SOLVED

I am attempting to set up a Seven Segment display using the SevSeg library. I have wired it as follows:

#include "SevSeg.h"
#include <IRremote.hpp>
SevSeg sevseg;

const int RECV_PIN = 10;

void setup() {
  Serial.begin(115200);
  IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK);
  byte numDigits = 1;
  byte digitPins[] = {};
  byte segmentPins[] = {6, 5, 2, 3, 4, 7, 8, 9};
  bool resistorsOnSegments = true;

  byte hardwareConfig = COMMON_CATHODE;
  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
  sevseg.setBrightness(90);
  sevseg.blank();
}

void loop() {
  

  if (IrReceiver.decode()) {

    IrReceiver.resume(); // Enable receiving of the next value

    // IrReceiver.printIRResultShort(&Serial);
    switch (IrReceiver.decodedIRData.command)
    {
      case 0x16:
        sevseg.setNumber(0);
        sevseg.refreshDisplay();
        Serial.println("0");
        break;
    }
}

The issue I am having is that when the code first starts up the bottom left segment is illuminated. Once it goes through the above switch statement, the bottom left segment will behave as expected. As a note I have trimmed the code to remove the rest of the switch statement

First you should wire the display correctly. Each segment should have a current limit resistor. Remove the 1K from the cathode. Connect the common cathode directly to ground.

What pin is used for IR_RECEIVE_PIN?

Seems like a bad idea to declare the pins for the display inside setup, unless the library makes a copy of the arrays they will contain undefined values once the code exits setup and the variables go out of scope.

Did not include the SevSeg library either so the posted code won't even compile. Needs work.

Rewiring the ground pins as you suggested solved the issue. Pin 10 is being used for IR_RECEIVE_PIN

New to the forums did not know we would need to attach a copy of the library. I have edited the code to add the includes

Did you install resistors (as shown ) on the segments?

I have not used the library before but I presume once sevseg.begin is called the arrays are no longer needed

Please do not change the posted code. Now our questions look stupid. If you make changes put the new code into a new post.

My bad will keep that in mind for future

You did post the code properly, in code tags, in your first post so you get some points for that. :+1: Most new members have to be reminded to read the guidelines.

For a brief test I did not, what size of resistor 220?

Used to sharing code via MS Teams so got that down at least, the more specific rules I gotta learn

220 is OK, but I would not go lower. A bit higher (330, 470) would not use as much current and would be good if the brightness is OK.

Going without resistors risks the display and/or the Arduino pins.

Wonderful thank you

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.