/********* Pleasedontcode.com **********
Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- Terms and Conditions:
You have a non-exclusive, revocable, worldwide, royalty-free license
for personal and commercial use. Attribution is optional; modifications
are allowed, but you're responsible for code maintenance. We're not
liable for any loss or damage. For full terms,
please visit pleasedontcode.com/termsandconditions.
- Project: "LED Display"
- Source Code NOT compiled for: ESP32 DevKit V1
- Source Code created on: 2024-06-11 22:48:13
********* Pleasedontcode.com **********/
/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
/* Generate an 8x8 LED matrix using WS2801 LEDs */
/* controlled by FastLED library. Display the string */
/* "pleasedontcode" on the matrix, showing each */
/* character every 0.5 seconds using digital pins D4 */
/* and D13 for data and clock. */
/****** END SYSTEM REQUIREMENTS *****/
/****** DEFINITION OF LIBRARIES *****/
#include //https://github.com/FastLED/FastLED
/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void updateOutputs(void);
void displayCharacter(char c);
/***** DEFINITION OF DIGITAL OUTPUT PINS *****/
const uint8_t strip_WS2801_DIN_PIN_D4 = 4;
const uint8_t strip_WS2801_CIN_PIN_D13 = 13;
/***** DEFINITION OF OUTPUT RAW VARIABLES *****/
/***** used to store raw data *****/
bool strip_WS2801_DIN_PIN_D4_rawData = 0;
bool strip_WS2801_CIN_PIN_D13_rawData = 0;
/***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
/***** used to store data after characteristic curve transformation *****/
float strip_WS2801_DIN_PIN_D4_phyData = 0.0;
float strip_WS2801_CIN_PIN_D13_phyData = 0.0;
/****** DEFINITION OF LIBRARIES CLASS INSTANCES*****/
#define NUM_LEDS 64
#define DATA_PIN 4
#define CLOCK_PIN 13
#define BRIGHTNESS 64
CRGB leds[NUM_LEDS];
const uint8_t kMatrixWidth = 8;
const uint8_t kMatrixHeight = 8;
const bool kMatrixSerpentineLayout = true;
/****** CHARACTER BITMAPS *****/
// Define bitmaps for characters 'a' to 'z' and space
const uint8_t charBitmaps[27][8] = {
// 'a'
{0b00000000, 0b01100000, 0b10010000, 0b10000000, 0b11110000, 0b10010000, 0b10010000, 0b01100000},
// 'b'
{0b00000000, 0b11100000, 0b10010000, 0b10010000, 0b11100000, 0b10010000, 0b10010000, 0b11100000},
// 'c'
{0b00000000, 0b01100000, 0b10010000, 0b10000000, 0b10000000, 0b10000000, 0b10010000, 0b01100000},
// 'd'
{0b00000000, 0b11100000, 0b10010000, 0b10010000, 0b10010000, 0b10010000, 0b10010000, 0b11100000},
// 'e'
{0b00000000, 0b11110000, 0b10000000, 0b10000000, 0b11100000, 0b10000000, 0b10000000, 0b11110000},
// 'f'
{0b00000000, 0b11110000, 0b10000000, 0b10000000, 0b11100000, 0b10000000, 0b10000000, 0b10000000},
// 'g'
{0b00000000, 0b01100000, 0b10010000, 0b10000000, 0b10110000, 0b10010000, 0b10010000, 0b01100000},
// 'h'
{0b00000000, 0b10010000, 0b10010000, 0b10010000, 0b11110000, 0b10010000, 0b10010000, 0b10010000},
// 'i'
{0b00000000, 0b11100000, 0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b11100000},
// 'j'
{0b00000000, 0b11110000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b10010000, 0b01100000},
// 'k'
{0b00000000, 0b10010000, 0b10100000, 0b11000000, 0b11000000, 0b10100000, 0b10010000, 0b10010000},
// 'l'
{0b00000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b10000000, 0b11110000},
// 'm'
{0b00000000, 0b10010000, 0b11110000, 0b11110000, 0b10101000, 0b10101000, 0b10101000, 0b10101000},
// 'n'
{0b00000000, 0b10010000, 0b11010000, 0b11010000, 0b10110000, 0b10110000, 0b10010000, 0b10010000},
// 'o'
{0b00000000, 0b01100000, 0b10010000, 0b10010000, 0b10010000, 0b10010000, 0b10010000, 0b01100000},
// 'p'
{0b00000000, 0b11100000, 0b10010000, 0b10010000, 0b11100000, 0b10000000, 0b10000000, 0b10000000},
// 'q'
{0b00000000, 0b01100000, 0b10010000, 0b10010000, 0b10010000, 0b10110000, 0b01100000, 0b00010000},
// 'r'
{0b00000000, 0b11100000, 0b10010000, 0b10010000, 0b11100000, 0b10100000, 0b10010000, 0b10010000},
// 's'
{0b00000000, 0b01100000, 0b10010000, 0b10000000, 0b01100000, 0b00010000, 0b10010000, 0b01100000},
// 't'
{0b00000000, 0b11100000, 0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b01000000, 0b01000000},
// 'u'
{0b00000000, 0b10010000, 0b10010000, 0b10010000, 0b10010000, 0b10010000, 0b10010000, 0b01100000},
// 'v'
{0b00000000, 0b10010000, 0b10010000, 0b10010000, 0b10010000, 0b10010000, 0b01100000, 0b01100000},
// 'w'
{0b00000000, 0b10101000, 0b10101000, 0b10101000, 0b10101000, 0b10101000, 0b11110000, 0b10010000},
// 'x'
{0b00000000, 0b10010000, 0b10010000, 0b01100000, 0b01100000, 0b01100000, 0b10010000, 0b10010000},
// 'y'
{0b00000000, 0b10010000, 0b10010000, 0b10010000, 0b01110000, 0b00010000, 0b10010000, 0b01100000},
// 'z'
{0b00000000, 0b11110000, 0b00010000, 0b00100000, 0b01000000, 0b10000000, 0b10000000, 0b11110000},
// ' '
{0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000}
};
/****** FUNCTION DEFINITIONS *****/
void setup(void)
{
// put your setup code here, to run once:
pinMode(strip_WS2801_DIN_PIN_D4, OUTPUT);
pinMode(strip_WS2801_CIN_PIN_D13, OUTPUT);
// Initialize the FastLED library
FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
void loop(void)
{
// put your main code here, to run repeatedly:
updateOutputs(); // Refresh output data
// Display the string "pleasedontcode"
const char* message = "pleasedontcode";
for (int i = 0; message[i] != '\0'; i++) {
displayCharacter(message[i]);
FastLED.show();
delay(500);
}
}
void updateOutputs()
{
digitalWrite(strip_WS2801_DIN_PIN_D4, strip_WS2801_DIN_PIN_D4_rawData);
digitalWrite(strip_WS2801_CIN_PIN_D13, strip_WS2801_CIN_PIN_D13_rawData);
}
uint16_t XY(uint8_t x, uint8_t y) {
uint16_t i;
if (kMatrixSerpentineLayout) {
i = (y & 0x01) ? (y * kMatrixWidth) + (kMatrixWidth - 1 - x) : (y * kMatrixWidth) + x;
} else {
i = (y * kMatrixWidth) + x;
}
return i;
}
void displayCharacter(char c) {
int index = (c == ' ') ? 26 : (c - 'a');
for (uint8_t y = 0; y < kMatrixHeight; y++) {
for (uint8_t x = 0; x < kMatrixWidth; x++) {
if (charBitmaps[index][y] & (1 << (7 - x))) {
leds[XY(x, y)] = CRGB::White;
} else {
leds[XY(x, y)] = CRGB::Black;
}
}
}
}