So far I have seen in LED matrix related projects that the brightness is controlled in an entirety manner. That means the brightness of total display can either be reduced or increased. How can we display only a part of the display with more brighter than the remaining matrix? Appreciate if anyone provide some pseudo logic to achieve this.
There's two options:
- Use a matrix driver that supports different brightnesses per pixel, or:
- Rapidly display a different arrangement of pixels in quick succession. The pixels that are on more often are brighter.
Option 1 basically does option 2 in hardware.
The theory is simple: For one LED you can vary the brightness by using PWM - that switches the LED on and off very rapidly. The longer it is on the brighter it appears.
You can do the same with a matrix of pixels. Instead of dealing with one pixel though you are dealing with, in effect, a series of "images". Each "image" has a different combination of pixels. The more "images" you have the greater variation you can get in your pixel brightnesses.
For example if you first display a frame of:
. . . . . . . . . . # # # # . . . # . . . . # . . # . . . . # . . # . . . . # . . # . . . . # . . . # # # # . . . . . . . . . .
followed by the image:
. . . . . . . # . . # # # # # . . # . . . # # . . # . . # . # . . # . # . . # . . # # . . . # . . # # # # # . . # . . . . . . .
then you will get a bright circle(ish) shape with a dimmer slash through it.
The only problem with this method is flicker. You have to have your matrix refreshing very fast. The more "images" you have to display in sequence the more it will flicker and the faster you will have to refresh your matrix to compensate.
Short answer: You likely can't, at a hardware level.
The only way you'd be able to do this is to vary the duty cycle of each individual LED in the matrix (the percent of on-time vs. off-time).
The device would have to support that. Edit your question with the model number of the LED matrix you're using and it's spec sheet.
(Note that if you're using a simple grid of LEDs and row/column addressing you could use PWM to get some control over brightness, but you'd probably already be using multiplexing of the LEDs, which makes varying brightness per LED more complex.)
LED brightness is normally controlled by how long a given LED is lit. An LED that is on for 70ms and off for 30ms will be brighter then an LED that is on for only 30ms and off for 70ms.
So, the answer is to shorten the amount of time which the LED is on and lethen the time the LED is off for only those LEDs in your display which are to be dimmer.
This is usually referred to as the duty cycle of the LED. On an Arduino, the PWM or Pulse Width Modulator feature of the embedded processor is normally used to create the duty cycle signal for an LED.
Depends on what LEDs your matrix is made of. One option would be to make it from 'smart' LEDs at each location, such as WS2812B. These are a chip and 3 LEDs in one package, usually a 5050 size SMD package, but they can also be had in thru hole packages, and can be found built up into boards also (look at Sparkfun and Adfruit for examples). Serial data is sent in, with a 0-255 value for each LED, the control chip then drives the 3 LEDs with the PWM level commanded - 0/255 for off, 128/255 for 1/2 on for example, 255/255 for full on. The data is passed from device to device to load them up, so for example an 8x8 matrix would need 8x8x3 = 192 bytes of data sent in to load the display. The Arduino then doesn't need to do any more until the matrix needs to change. WS2812B needs some fancy timing to send in 0/1 data in a combined data/clock signal line, options are the Neopixel library or the FastLed.h library for Arduino, to send data in at up to 800 KHz rate. There is also another version of the chip that uses seperate clock and data lines, SPI.transfer I think can be used to send in data even faster. I don't recall that device's part number off hand, I've not used it.
For premade 8x8 modules using single color LEDs, then as described in other answers MAX7219 is often used, with 15 levels of brightness available for the whole display.