I'm trying to add a 4-digit 7-segment display to an existing project (a temperature & relative humidity sensor) to show the temperature on the display.

I bought the display a long time ago and I it doesn't have any ID and I don't have any reference to a schematic, so I followed this article to find out both if it's a common cathode or anode and the pinout.

It turns out it's a common cathode display and the pinout goes like this (numbered from upper left):

1 -> D1
2 -> A
3 -> F
4 -> D2
5 -> D3
6 -> B
7 -> E
8 -> D
9 -> DP
10 -> C
11 -> G
12 -> D4

Where D{1,2,3,4} are the digit control pins and the rest are the segments.

So I added the SevSeg library to my project. And the sketch compiles, but when I upload it to my Arduino Uno all the LEDs in the digits 1 and 4 light up and digits two and three remain off.

I checked the pinout twice, with the same results and the display doesn't seem to be damaged. Do you see any issue on my code?

Thanks in advance!

  • isolate the area of failure ... switch the digit pin wires ... see if the problem is with the display, or with program
    – jsotola
    Aug 17 '20 at 20:19
  • Be sure, that you don't connect anything to the pins used by the ethernet shield
    – chrisl
    Aug 18 '20 at 15:37
  • instructables.com/… This maybe helpful... I used this and this worked.
    – Hasan
    Jan 2 '21 at 12:29

What caused the problem of the digit that driven by pin 12 is quite obvious to me. You use pin 11, 12, 13, 14 for driving the 7-segment digits. While SPI library by default uses pin 10, 11, 12, 13 as SS, MOSI, MISO and SCK, and set pin 12 (MISO) as INPUT which is in conflict with your pin 12 (as an OUTPUT) for driving the digit.

Pin 13 is also used by the interval blinking LED (i.e. BUILTIN_LED) when defined as a digital i/o.

Your code uses quite a few libraries, and those libraries could uses some of the I/O pins, I would suggest you reduce your code to only the code related to SevSeg, set the display to all '8888', and add each library one by one back to find out what caused the problem.


Your issue could be in code or in your hardware.

To work out which one, try running one of the example sketches like the testWholeDisplay.ino that comes with the library you are using. This way you have known working code and you are testing that your hardware is wired up correctly. If this step doesn't work, then you need to look into your wiring and/or setup.

If using the example sketch works, then you can start looking into your sketch. Divide it into chunks and test each chunk independently. If any chunk doesn't work then work out what is different from the example sketches compared to your code.

  • You're right, I used the example and the display works fine. The problem may be what @hcheung says, so I'll try to free the pins 11, 12, 13, 14 and use the analog pins as digital pins instead. Another option would be to use a LED driver. Oct 25 '20 at 20:44

Reverse engineering your code, which is generated by https://examples.blynk.cc, I have found that you are using:

Your Blynk example code looked something like this.

For the 7 segment display you are using pins 3, 5, 6, 7, 8, 9, 11, 12, 13, A0, A1, A2.

byte digitPins[] = { 11, 12, 13, A2};
byte segmentPins[] = {3, A0, 5, 6, 7, 8, 9, A1};

However, the W5100 Ethernet controller uses pins 10, 11, 12 and 13 as seen on the Arduino Ethernet webpage:

NB: Pins 10, 11, 12 and 13 are reserved for interfacing with the Ethernet module and should not be used otherwise. This reduces the number of available pins to 9, with 4 available as PWM outputs.

Pins 2 & 4 are used for the DHT11 and SD card chip select respectively.

All you have to do is change the wiring of the seven segment display to not use pins 11, 12 and 13, and then adjust your sketch accordingly. For example, you could use A3, A4 & A5.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.