Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // twist pattern
- //fastled 16x16 matrix demo
- //Yaroslaw Turbin 21.08.2020
- #include "FastLED.h"
- // Matrix size
- #define NUM_ROWS 16
- #define NUM_COLS 16
- // LEDs pin
- #define DATA_PIN 3
- // LED brightness
- #define BRIGHTNESS 255
- #define NUM_LEDS NUM_ROWS * NUM_COLS
- // Define the array of leds
- CRGB leds[NUM_LEDS];
- byte hue =0;
- void setup() {
- FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
- FastLED.setBrightness(BRIGHTNESS);
- }
- void loop() {
- for (uint8_t i = 0; i < NUM_COLS; i+=4) {
- for (uint8_t j = 0; j < NUM_ROWS; j+=4) {
- patt1 (i,j, 128+hue+j*2, hue+i*2);
- patt2 (i+2,j, 128+hue+j*2,hue+i*2);
- patt2 (i,j+2, 128+hue+j*2,hue+i*2);
- patt1 (i+2,j+2, 128+hue+j*2,hue+i*2);
- }}
- FastLED.delay(10);
- hue +=1;
- }
- uint16_t XY (uint8_t x, uint8_t y) { return (y * NUM_COLS + x);}
- void patt1 (uint8_t i, uint8_t j, uint8_t color1, uint8_t color2 ) {
- // leds[XY (i, j)] = CHSV (0, 255, 0); //color of background
- leds[XY (i+1, j)] = CHSV (color1, 255, BRIGHTNESS);
- leds[XY (i+1, j+1)] = CHSV (color1, 255, BRIGHTNESS);
- leds[XY (i, j+1)] = CHSV (color2, 255, BRIGHTNESS);
- }
- void patt2 (uint8_t i, uint8_t j, uint8_t color1, uint8_t color2) {
- // leds[XY (i, j)] = CHSV (0, 255, 0); //color of background
- leds[XY (i+1, j)] = CHSV (color1, 255, BRIGHTNESS);
- leds[XY (i+1, j+1)] = CHSV (color2, 255, BRIGHTNESS);
- leds[XY (i, j+1)] = CHSV (color2, 255, BRIGHTNESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement