Arduino Nano 33 IoT - 10 Segment LED Bar Graph

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×Optionally, DC Power Jack
1×10 Segment LED Bar Graph
10×220 Ω Resistor
1×Breadboard
1×Jumper Wires
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

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 tutorial instructs you how to use Arduino Nano 33 IoT to control the 10 Segment LED Bar Graph display. In detail, we will learn:

Arduino Nano 33 IoT and 10 Segment LED Bar Graph

Overview of 10 Segment LED Bar Graph

A 10 Segment LED Bar Graph is a compact display component consisting of ten individual LED segments arranged in a row. Each segment can be controlled independently, making it ideal for visualizing levels, progress, or any value that ranges from 0 to 10.

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

The 10 Segment LED Bar Graph Pinout

10 Segment LED Bar Graph pinout

The component has two rows of pins — anodes and cathodes — one per segment:

  • Anode pins (A1–A10): must be connected to GPIO pins via 220Ω resistors
  • Cathode pins (K1–K10): must be connected to GND

※ NOTE THAT:

Pin numbering on LED bar graphs can vary between manufacturers. It is essential to always verify the anode and cathode orientation before wiring. Refer to the datasheet or check the component labeling carefully.

Wiring Diagram

Connect the 10 Segment LED Bar Graph to the Arduino Nano 33 IoT as shown in the table below.

The wiring diagram between Arduino Nano and 33 IoT and 10 Segment LED Bar Graph

This image is created using Fritzing. Click to enlarge image

LED Bar Graph Arduino Nano 33 IoT Pin
A1 (Anode 1) Pin 2 (via 220Ω)
A2 (Anode 2) Pin 3 (via 220Ω)
A3 (Anode 3) Pin 4 (via 220Ω)
A4 (Anode 4) Pin 5 (via 220Ω)
A5 (Anode 5) Pin 6 (via 220Ω)
A6 (Anode 6) Pin 7 (via 220Ω)
A7 (Anode 7) Pin 8 (via 220Ω)
A8 (Anode 8) Pin 9 (via 220Ω)
A9 (Anode 9) Pin 10 (via 220Ω)
A10 (Anode 10) Pin 11 (via 220Ω)
K1–K10 (Cathodes) GND

How To Program Arduino Nano 33 IoT for 10 Segment LED Bar Graph

  • The first step is to specify the pins connected to the anode pins of the LED bar graph
  • Configure each pin as digital output using pinMode()
  • Set a GPIO pin HIGH to illuminate the corresponding LED segment
  • Set a GPIO pin LOW to turn off the segment
  • No external library is required for this project

Arduino Nano 33 IoT Code for 10 Segment LED Bar Graph

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-10-segment-led-bar-graph */ const int NUM_SEGMENTS = 10; const int ledPins[NUM_SEGMENTS] = {2, 3, 4, 5, 6, 7, 8, 9, 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

If this is the first time you use Arduino Nano 33 IoT, see how to set up the environment for Arduino Nano 33 IoT in Arduino IDE.

  • Wire the components as shown in the diagram.
  • Connect the Arduino Nano 33 IoT board to your computer using a Micro USB cable.
  • Open the Arduino IDE on your computer.
  • Select the correct board: go to ToolsBoardArduino SAMD BoardsArduino NANO 33 IoT.
  • Select the correct COM port: go to ToolsPort and choose the port associated with your Arduino Nano 33 IoT.
  • Copy the code above and paste it into the Arduino IDE.
  • Click the Upload button to compile and upload the code to the board.
  • Open the Serial Monitor: go to ToolsSerial Monitor, and set the baud rate to 9600.
  • Observe the LED bar graph fill segment by segment from left to right, then empty from right to left in a repeating animation.

Serial Monitor Output

Newbiely | Arduino IDE 2.3.8
──
File
Edit
Sketch
Tools
Help
Arduino Nano 33 IoT
Newbiely.ino
···
8 Serial.println("Hello World!");
Output
Serial Monitor
Message (Enter to send message to 'Arduino Nano 33 IoT' 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
Arduino Nano 33 IoT on COM15
2

Additional Knowledge

The LED bar graph project can be extended in a number of practical ways:

Reading an analog sensor to drive the bar: An analog sensor such as a potentiometer or an LDR (light-dependent resistor) can be connected to one of the Arduino Nano 33 IoT's analog input pins. The analog reading (0–1023) can then be mapped to the number of lit segments (0–10) using the map() function:

int sensorValue = analogRead(A0); int litCount = map(sensorValue, 0, 1023, 0, NUM_SEGMENTS);

This allows the LED bar to visually represent the sensor level in real time.

Wireless streaming with Arduino Nano 33 IoT: The Arduino Nano 33 IoT includes built-in Wi-Fi and Bluetooth via the u-blox NINA-W102 module. This wireless capability can be used to transmit the current LED bar state — for example, the number of lit segments — to a remote dashboard, a mobile application, or a web browser. The WiFiNINA library provides straightforward support for establishing Wi-Fi connections and sending data over TCP or UDP sockets. Similarly, the ArduinoBLE library can be used to broadcast the bar state over Bluetooth Low Energy to a paired device.

Video Tutorial

※ 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!