/********************************************************************************
n this example, I've represented the smiley face emoji as a pixel pattern
in a 1D array. The number "1" in the array represents the pixel color for
the eyes and mouth,
while "0" represents a blank pixel. You can modify the pattern array for
different emojis by designing a 16x16 pixel art and converting it
into a similar 1D array format.
Note that for more complex emojis, you may want to consider using larger
LED matrices or multiple smaller matrices to ensure you have enough resolution to represent the details of the emoji accurately.
*************************************************************************************/
#include <FastLED.h>
#define LED_MATRIX_PIN 3
#define LED_MATRIX_WIDTH 16
#define LED_MATRIX_HEIGHT 16
CRGB leds[LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT];
void setup() {
// Initialize FastLED with the LED matrix configuration
FastLED.addLeds<NEOPIXEL, LED_MATRIX_PIN>(leds, LED_MATRIX_WIDTH * LED_MATRIX_HEIGHT);
FastLED.setBrightness(200); // Adjust this value to set the brightness of the LEDs
}
void loop() {
// Call your emoji display function here
displaySmileyFace();
}
// Function to display the smiley face emoji on the LED matrix
void displaySmileyFace() {
// Smiley face emoji pattern in a 1D array (16x16)
uint8_t smileyFace[256] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 pixels (row 1)
0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, // 16 pixels (row 2)
0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, // 16 pixels (row 3)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 pixels (row 4)
0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, // 16 pixels (row 5)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 pixels (row 6)
0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, // 16 pixels (row 7)
0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 16 pixels (row 8)
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 pixels (row 9)
0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, // 16 pixels (row 10)
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, // 16 pixels (row 11)
0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, // 16 pixels (row 12)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 pixels (row 13)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 pixels (row 14)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 pixels (row 15)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 pixels (row 16)
};
// Copy the emoji pattern to the LED matrix
for (int y = 0; y < LED_MATRIX_HEIGHT; y++) {
for (int x = 0; x < LED_MATRIX_WIDTH; x++) {
// Calculate the index in the 1D array based on the 2D position
int ledIndex = y * LED_MATRIX_WIDTH + x;
// Set the LED color based on the pixel value in the emoji pattern
leds[ledIndex] = (smileyFace[ledIndex] == 1) ? CRGB(255, 0, 43) : CRGB::CRGB::Cyan;
}
}
// Show the LEDs
FastLED.show();
// Delay to control the display time (adjust as needed)
delay(100); // Display the emoji for 1 second before looping again
}
FPS: 0
Power: 0.00W
Power: 0.00W