ESP32 S3 UNO - 10 Segment LED Bar Graph

1×ESP32 S3 Uno-form Board
1×USB Cable Type-A to Type-C (for USB-A PC)
1×USB Cable Type-C to Type-C (for USB-C PC)
1×10 Segment LED Bar Graph
10×220 Ω Resistor
1×Breadboard
1×Jumper Wires

Or you can buy the following kits:

1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

This ESP32 S3 Uno 10 segment LED bar graph tutorial shows you how to wire the bar graph to the ESP32 S3 Uno form board and control each segment with Arduino code. You will turn the LED bar display into a small animation that fills up one segment at a time and then empties again.

In this tutorial, you will:

  1. Wire a 10 segment LED bar graph to the ESP32 S3 Uno
  2. Add a 220Ω resistor to every LED segment
  3. Turn each segment on and off with digitalWrite()
  4. Animate the LED bar display and print it on the Serial Monitor
ESP32 S3 Uno 10 segment LED bar graph

Overview of 10 Segment LED Bar Graph

An LED bar graph is a quick way to show a level, such as volume, battery charge or signal strength. One small part gives you ten lights in a neat row, so you do not need ten loose LEDs.

The 10 segment LED bar graph has ten red LED segments side by side. Each segment has its own anode and cathode pin, so you can switch every segment on its own.

10 Segment LED Bar Graph
Number of Segments 10
LED Color Bright red
Forward Voltage ~2V per segment
Forward Current 20mA max per segment
Resistor Required 220Ω per segment

Pinout

10 Segment LED Bar Graph pinout

The bar graph has 20 pins in total. Each of the ten segments has one anode and one cathode.

Anode pins (A1–A10)

These are the positive side of each segment. Connect each one to an ESP32 S3 Uno pin through its own 220Ω resistor.

Cathode pins (K1–K10)

These are the negative side of each segment. Connect all of them to GND.

ESP32 S3 Uno Pinout

The image below shows the pinout of the ESP32 S3 Uno form board. Use it to find the Uno header pins (D2 to D11) and their GPIO numbers when you wire the bar graph.

ESP32 S3 Uno pinout diagram

Wiring Diagram between 10 Segment LED Bar Graph and ESP32 S3 Uno

Each anode goes to one digital pin through a 220Ω resistor, and all cathodes go to GND. The resistors limit the current, so the LEDs and the ESP32 S3 Uno pins stay safe.

The wiring diagram between ESP32 S3 Uno and 10 Segment LED Bar Graph

This image is created using Fritzing. Click to enlarge image

LED Bar Graph ESP32 S3 Uno Pin
A1 (Anode 1) D2 (GPIO18) via 220Ω
A2 (Anode 2) D3 (GPIO17) via 220Ω
A3 (Anode 3) D4 (GPIO19) via 220Ω
A4 (Anode 4) D5 (GPIO20) via 220Ω
A5 (Anode 5) D6 (GPIO3) via 220Ω
A6 (Anode 6) D7 (GPIO14) via 220Ω
A7 (Anode 7) D8 (GPIO21) via 220Ω
A8 (Anode 8) D9 (GPIO46) via 220Ω
A9 (Anode 9) D10 (GPIO10) via 220Ω
A10 (Anode 10) D11 (GPIO11) via 220Ω
K1–K10 (Cathodes) GND

WARNING

D6 (GPIO3) and D9 (GPIO46) are boot strapping pins on the ESP32 S3 Uno. The board reads them at startup to pick the boot mode. With a 220Ω resistor and an LED to GND this circuit normally works, but if the board does not boot or fails to upload, unplug the wires from D6 and D9, upload the code, then connect them again.

How To Program ESP32 S3 Uno for 10 Segment LED Bar Graph

You do not need any library for this project. Each segment is just one LED, so the normal digital pin functions are enough.

  1. Put the ten anode pins in an array, using the GPIO numbers: const int ledPins[10] = {18, 17, 19, 20, 3, 14, 21, 46, 10, 11};
  2. In setup(), set every pin in the array as an output.
  3. To light segment i, call digitalWrite(ledPins[i], HIGH);
  4. To turn segment i off, call digitalWrite(ledPins[i], LOW);

ESP32 S3 Uno Code - 10 Segment LED Bar Graph

The sketch lights the segments one by one from the first to the last, waits half a second, and then switches them off in reverse order. Each step also prints a small text bar on the Serial Monitor, so you can follow the animation on your screen.

/* * This ESP32 S3 Uno code was developed by newbiely.com * * This ESP32 S3 Uno code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/esp32-s3-uno/esp32-s3-uno-10-segment-led-bar-graph */ const int NUM_SEGMENTS = 10; // ESP32 S3 Uno GPIOs for Uno header pins D2, D3, D4, D5, D6, D7, D8, D9, D10, D11 const int ledPins[NUM_SEGMENTS] = {18, 17, 19, 20, 3, 14, 21, 46, 10, 11}; void printBar(int litCount) { Serial.print("Bar: ["); for (int i = 0; i < NUM_SEGMENTS; i++) { Serial.print(i < litCount ? "*" : " "); } Serial.println("]"); } void setup() { Serial.begin(9600); for (int i = 0; i < NUM_SEGMENTS; i++) { pinMode(ledPins[i], OUTPUT); digitalWrite(ledPins[i], LOW); } } void loop() { for (int i = 0; i < NUM_SEGMENTS; i++) { digitalWrite(ledPins[i], HIGH); printBar(i + 1); delay(100); } delay(500); for (int i = NUM_SEGMENTS - 1; i >= 0; i--) { digitalWrite(ledPins[i], LOW); printBar(i); delay(100); } delay(500); }

Detailed Instructions

  1. New to the ESP32 S3 Uno? Follow ESP32 S3 Uno - Getting Started first.
  2. Wire it up as shown in the diagram, with one 220Ω resistor on every anode.
  3. Connect the board to your computer with a USB Type-C cable.
  4. Open Arduino IDE, choose the ESP32S3 Dev Module board and the correct COM port.
  5. Copy the code above and paste it into the Arduino IDE.
  6. Upload the code by clicking the Upload button.
  7. Open the Serial Monitor and set the baud rate to 9600.
  8. Watch the bar graph fill up segment by segment, empty back down, and repeat.
  9. Tip: change the delay(100) value to make the animation faster or slower.

Serial Monitor Output

∞
Newbiely | Arduino IDE 2.3.8
──
☐
✕
File
Edit
Sketch
Tools
Help
ESP32S3 Dev Module
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'ESP32S3 Dev Module' on 'COM15')
New Line
9600 baud
Bar: [* ] Bar: [** ] Bar: [*** ] Bar: [**** ] Bar: [***** ] Bar: [****** ] Bar: [******* ] Bar: [******** ] Bar: [********* ] Bar: [**********] Bar: [********* ] Bar: [******** ] Bar: [******* ] Bar: [****** ] Bar: [***** ] Bar: [**** ] Bar: [*** ] Bar: [** ] Bar: [* ] Bar: [ ]
Ln 11, Col 1
ESP32S3 Dev Module on COM15
2

Video Tutorial

Watch the video below to see this ESP32 S3 Uno project step by step.

FAQ

Can I connect the LED bar graph directly to the ESP32 S3 Uno without resistors?

No. Each segment needs its own 220Ω resistor. Without it, too much current flows through the LED and the GPIO pin. This can burn the segment or damage the ESP32 S3 Uno pin.

Is the 3.3V output of the ESP32 S3 Uno enough to light the bar graph?

Yes. Each red segment needs about 2V, so a 3.3V pin is enough. With a 220Ω resistor the current is about 6mA per segment. The LEDs are a little less bright than on a 5V board, but they are clearly visible.

Why does the code use numbers like 18 and 46 instead of 2 and 9?

On the ESP32 S3 Uno, the header labels (D2, D9…) are not the same as the GPIO numbers. In code you must write the GPIO number. For example, D2 is GPIO18 and D9 is GPIO46. The wiring table shows both.

Can I control the brightness of the segments?

Yes. Every pin used here supports PWM on the ESP32 S3 Uno. Replace digitalWrite() with analogWrite(pin, value), where value is 0 to 255.

What if my project needs more pins than the Uno headers give?

This project uses ten header pins, so you may run out if you add buttons or sensors. The ESP32 S3 Uno has two extra rows of holes with more GPIOs: GPIO15 and GPIO16 (I/O, PWM, analog), GPIO45 and GPIO35–GPIO42 (I/O, PWM), and GPIO47/GPIO48 (output only, PWM). Solder pin headers to use them and write the GPIO number in code. GPIO35–GPIO42 are a good choice for extra LEDs or buttons, and GPIO15/16 for an analog sensor that sets the bar level. Two warnings: GPIO47/GPIO48 may run at 1.8V instead of 3.3V on some modules (especially ones with "V" in the name, like R8V or R16V), so 3.3V devices can be damaged or act strangely. Also, GPIO0, GPIO3 (D6), GPIO45 and GPIO46 (D9) are boot strapping pins, and a wrong connection can stop the board from booting or uploading code. Use the other extra pins first.

Troubleshooting

Problem Possible Cause Solution
No COM port shows up in Arduino IDE USB driver missing or charge-only cable Install the CP210x or CH340 driver, use a data USB cable, or hold BOOT while pressing RESET
Upload fails or board does not boot D6 (GPIO3) or D9 (GPIO46) strapping pin pulled the wrong way Unplug the wires from D6 and D9, upload, then connect them again
No segment lights up Bar graph inserted backwards or cathodes not on GND Turn the bar graph around and check that all cathodes go to GND
One segment never lights Loose wire, wrong resistor or burnt segment Check the wire and resistor for that anode, then test the segment with another pin
Segments light in the wrong order Anode wires swapped on the header Compare each wire with the wiring table and fix the order
LEDs are very dim Resistor value too high Use 220Ω resistors, not 2.2kΩ or 10kΩ
Serial Monitor shows strange characters Wrong baud rate Set the Serial Monitor to 9600 baud

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!