# Arduino+ws2812 What is the maximum refresh rate？I wanted to make a number that wouldn't refresh visible to the human eye, but it didn't. LED panels 16

**URL:** <https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075>\
**Category:** LEDs and Multiplexing\
**Created:** [October 31, 2024, 7:49am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075 "2024-10-31T07:49:57Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![zyh\_learning](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zyh_learning/32/1116792_2.png) [@zyh\_learning](https://forum.arduino.cc/u/zyh_learning)\
**Post date:** [October 31, 2024, 7:49am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/1 "2024-10-31T07:49:57Z")

</div>

I want a lighting fixture with ID information for my research.

Inside the WS2812's 16 by 16 light board, first it lights up all the time, then embeds an ID that is invisible to the human eye.

My idea is to make this ID number flicker at a frequency above 50hz while the display dips in half. So it can be recognized by the camera.

But now the problem, I can not be invisible. Here is my code. Ask Friends for advice or give me ready-made code.

```arduino
#include <Adafruit_GFX.h> // Import the core graphics library for drawing and text handling
#include <Adafruit_NeoMatrix.h> // Import the NeoMatrix library for controlling the LED matrix
#include <Adafruit_NeoPixel.h> // Import the NeoPixel library, which NeoMatrix depends on
#include <TimerOne.h> // Import the TimerOne library for setting timer interrupts

#define PIN 5 // Define the data pin connected to the LED matrix

// Initialize the NeoMatrix object, set matrix size to 16x16, configure layout and color format
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(16, 16, PIN,
  NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_GRB + NEO_KHZ800);

const uint16_t FULL_WHITE = matrix.Color(255, 255, 255); // Define full white color
const uint16_t DIM_WHITE = matrix.Color(170, 170, 170); // Define dim white color for displaying numbers
const int BRIGHTNESS = 5; // Set matrix brightness

volatile bool showNumber = false; // Flag to control number display
volatile unsigned long lastShowTime = 0; // Record the last time the number was displayed
const unsigned long SHOW_INTERVAL = 1000; // Set display interval to 1 ms

void setup() {
  matrix.begin(); // Initialize the LED matrix
  matrix.setBrightness(BRIGHTNESS); // Apply brightness setting
  matrix.setTextWrap(false); // Disable automatic text wrapping
  
  // Set up Timer1 interrupt to trigger every 11 microseconds
  Timer1.initialize(999); // Initialize Timer1 with an interval of 999 microseconds
  Timer1.attachInterrupt(timerCallback); // Bind the timer interrupt callback function
}

void loop() {
  while(1) {
    if (showNumber) {
      displayNumber1(); // Display the number "1"
      delayMicroseconds(1); // Display the number for 1 microsecond
      showNumber = false; // Reset the display flag
      matrix.fillScreen(FULL_WHITE); // Clear the number and show full white
      matrix.show(); // Update the display
    }
  }
}

void timerCallback() {
  unsigned long currentTime = micros(); // Get the current time in microseconds
  if (currentTime - lastShowTime >= SHOW_INTERVAL) { // Check if the display interval has been reached
    showNumber = true; // Set the flag to display the number
    lastShowTime = currentTime; // Update the last display time
  }
}

void displayNumber1() {
  matrix.fillScreen(FULL_WHITE); // First set the background to full white
  matrix.setTextColor(DIM_WHITE); // Set the text color to dim white
  matrix.setTextSize(2); // Set the text size to 2
  matrix.setCursor(4, 0); // Set the cursor position for text display
  matrix.print("1"); // Display the number "1"
  matrix.show(); // Refresh the display
}

```

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [October 31, 2024, 9:06am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/2 "2024-10-31T09:06:05Z")

</div>

Only answering the question in the topic title.

One bit takes 1.25 microseconds. Multiply by 24 (3 bytes for r/g/b for one pixel) so that gives 30 microseconds.

Multiply that by the number of LEDs (256) and you get the time needed for a single refresh of all 256 LEDs.

---

<div class="post-metadata">

**Author:** ![zyh\_learning](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zyh_learning/32/1116792_2.png) [@zyh\_learning](https://forum.arduino.cc/u/zyh_learning)\
**Post date:** [October 31, 2024, 11:17am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/3 "2024-10-31T11:17:51Z")

</div>

thanks for you .  
yes,it takes about 7.68ms to refresh a complete matrix of 256 leds.  
And,theoretical maximum refresh rate: about 1000/7.68≈130hz  
The refresh rate is enough for the invisible .

---

<div class="post-metadata">

**Author:** ![david\_2018](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/david_2018/32/1013044_2.png) [@david\_2018](https://forum.arduino.cc/u/david_2018)\
**Post date:** [October 31, 2024, 11:57am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/4 "2024-10-31T11:57:57Z")

</div>

Be aware that interrupts are disabled while the data is being sent to the LEDs.

---

<div class="post-metadata">

**Author:** ![DaveX](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/davex/32/751443_2.png) [@DaveX](https://forum.arduino.cc/u/DaveX)\
**Post date:** [October 31, 2024, 12:07pm UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/5 "2024-10-31T12:07:18Z")

</div>

Plus the 50us pause to latch them:

> [@NeoPixel (using Adafruit\_NeoPixel) Affects Stepper Motor (using AccelStepper)](https://forum.arduino.cc/t/neopixel-using-adafruit-neopixel-affects-stepper-motor-using-accelstepper/1302534/22):
>
> From the Neopixel side, an update of 10 pixels should take `20*30us+50us = 300us` which should leave plenty of time for a step. [(Adafruit reference)](https://learn.adafruit.com/adafruit-neopixel-uberguide/advanced-coding#faq-2894689)

---

<div class="post-metadata">

**Author:** ![camsysca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/camsysca/32/1015228_2.png) [@camsysca](https://forum.arduino.cc/u/camsysca)\
**Post date:** [October 31, 2024, 1:23pm UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/6 "2024-10-31T13:23:41Z")

</div>

> [@zyh\_learning](#):
>
> 7.68ms

call it 8 ms. Would seem to indicate you could actually refresh at \> 120 Hz, with a well - designed code.  
To convince yourself that this is so, simply write a loop() that changes the colour of one pixel, then calls the update mechanism. When you've figured out what the real update rate is, then figure out what's wrong with your code. Hints:

- you don't need an interrupt process
- you don't need a timer
- you don't need most of what you've written
- whenever you find yourself using any form of a delay(), you're off the best path.
- explore the functionalities and limitations of that library. Write test code to see how long each of the functions you're calling actually takes, on whatever Arduino you're running this on.
- 

As for

> [@zyh\_learning](#):
>
> ```arduino
> if (showNumber) {
> displayNumber1(); // Display the number "1"
> delayMicroseconds(1); // Display the number for 1 microsecond
> showNumber = false; // Reset the display flag
> matrix.fillScreen(FULL_WHITE); // Clear the number and show full white
> matrix.show(); // Update the display
> 
> ```

Do you honestly expect you would see something displayed for 1 microsecond?

---

<div class="post-metadata">

**Author:** ![zyh\_learning](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zyh_learning/32/1116792_2.png) [@zyh\_learning](https://forum.arduino.cc/u/zyh_learning)\
**Post date:** [November 1, 2024, 2:37am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/7 "2024-11-01T02:37:53Z")

</div>

thanks point out my mistake，I have changed. 😀

---

<div class="post-metadata">

**Author:** ![zyh\_learning](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zyh_learning/32/1116792_2.png) [@zyh\_learning](https://forum.arduino.cc/u/zyh_learning)\
**Post date:** [November 1, 2024, 3:40am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/8 "2024-11-01T03:40:12Z")

</div>

❤I tried 4 lamp beads and found that they were achievable.

So now the problem is 256 beads of data transmission data too much, resulting in low refresh rate.[quote="zyh\_learning, post:1, topic:1317075, full:true"]  
I want a lighting fixture with ID information for my research.

Inside the WS2812's 16 by 16 light board, first it lights up all the time, then embeds an ID that is invisible to the human eye.

My idea is to make this ID number flicker at a frequency above 50hz while the display dips in half. So it can be recognized by the camera.

But now the problem, I can not be invisible. Here is my code. Ask Friends for advice or give me ready-made code.

```arduino
#include <Adafruit_GFX.h> // Import the core graphics library for drawing and text handling
#include <Adafruit_NeoMatrix.h> // Import the NeoMatrix library for controlling the LED matrix
#include <Adafruit_NeoPixel.h> // Import the NeoPixel library, which NeoMatrix depends on
#include <TimerOne.h> // Import the TimerOne library for setting timer interrupts

#define PIN 5 // Define the data pin connected to the LED matrix

// Initialize the NeoMatrix object, set matrix size to 16x16, configure layout and color format
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(16, 16, PIN,
  NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_COLUMNS + NEO_MATRIX_ZIGZAG,
  NEO_GRB + NEO_KHZ800);

const uint16_t FULL_WHITE = matrix.Color(255, 255, 255); // Define full white color
const uint16_t DIM_WHITE = matrix.Color(170, 170, 170); // Define dim white color for displaying numbers
const int BRIGHTNESS = 5; // Set matrix brightness

volatile bool showNumber = false; // Flag to control number display
volatile unsigned long lastShowTime = 0; // Record the last time the number was displayed
const unsigned long SHOW_INTERVAL = 1000; // Set display interval to 1 ms

void setup() {
  matrix.begin(); // Initialize the LED matrix
  matrix.setBrightness(BRIGHTNESS); // Apply brightness setting
  matrix.setTextWrap(false); // Disable automatic text wrapping
  
  // Set up Timer1 interrupt to trigger every 11 microseconds
  Timer1.initialize(999); // Initialize Timer1 with an interval of 999 microseconds
  Timer1.attachInterrupt(timerCallback); // Bind the timer interrupt callback function
}

void loop() {
  while(1) {
    if (showNumber) {
      displayNumber1(); // Display the number "1"
      delayMicroseconds(1); // Display the number for 1 microsecond
      showNumber = false; // Reset the display flag
      matrix.fillScreen(FULL_WHITE); // Clear the number and show full white
      matrix.show(); // Update the display
    }
  }
}

void timerCallback() {
  unsigned long currentTime = micros(); // Get the current time in microseconds
  if (currentTime - lastShowTime >= SHOW_INTERVAL) { // Check if the display interval has been reached
    showNumber = true; // Set the flag to display the number
    lastShowTime = currentTime; // Update the last display time
  }
}

void displayNumber1() {
  matrix.fillScreen(FULL_WHITE); // First set the background to full white
  matrix.setTextColor(DIM_WHITE); // Set the text color to dim white
  matrix.setTextSize(2); // Set the text size to 2
  matrix.setCursor(4, 0); // Set the cursor position for text display
  matrix.print("1"); // Display the number "1"
  matrix.show(); // Refresh the display
}

```

[/quote]

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [November 1, 2024, 5:52am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/9 "2024-11-01T05:52:36Z")

</div>

> [@zyh\_learning](#):
>
> And,theoretical maximum refresh rate: about 1000/7.68≈130hz  
> The refresh rate is enough for the invisible .

Be aware that in your code you refresh the matrix twice , so the maximum rate about 70hz

---

<div class="post-metadata">

**Author:** ![zyh\_learning](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zyh_learning/32/1116792_2.png) [@zyh\_learning](https://forum.arduino.cc/u/zyh_learning)\
**Post date:** [November 1, 2024, 7:28am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/10 "2024-11-01T07:28:00Z")

</div>

> [@b707](#):
>
> Be aware that in your code you refresh the matrix twice , so the maximum rate about 70hz

But it can't arrive the 50hz,because i can see the led is refresh.

---

<div class="post-metadata">

**Author:** ![b707](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/b707/32/854321_2.png) [@b707](https://forum.arduino.cc/u/b707)\
**Post date:** [November 1, 2024, 8:18am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/11 "2024-11-01T08:18:52Z")

</div>

> [@zyh\_learning](#):
>
> because i can see the led is refresh.

How did you seen it? By the camera?

---

<div class="post-metadata">

**Author:** ![zyh\_learning](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/zyh_learning/32/1116792_2.png) [@zyh\_learning](https://forum.arduino.cc/u/zyh_learning)\
**Post date:** [November 2, 2024, 10:41am UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/14 "2024-11-02T10:41:36Z")

</div>

when I only use a led，I set the flicker frequency, 10hz to 200hz of the increase in function, from flicker visible to normal light, the human eye can not be observed. 😀

---

<div class="post-metadata">

**Author:** ![camsysca](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/camsysca/32/1015228_2.png) [@camsysca](https://forum.arduino.cc/u/camsysca)\
**Post date:** [November 2, 2024, 12:35pm UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/15 "2024-11-02T12:35:32Z")

</div>

Which Arduino?  
I forget which pixel library it is, but there is a library that would write to more than one pin at the same time, allowing simultaneous update of, IIRC, up to 8 strings. Maybe, you could drive your16x16 as 8x32 that way.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 1, 2025, 12:35pm UTC](https://forum.arduino.cc/t/arduino-ws2812-what-is-the-maximum-refresh-rate-i-wanted-to-make-a-number-that-wouldnt-refresh-visible-to-the-human-eye-but-it-didnt-led-panels-16/1317075/16 "2025-05-01T12:35:38Z")

</div>

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