Created
March 13, 2026 15:35
-
-
Save chemdoc77/808b8d9f15c7f1f3f415b334d3157dd5 to your computer and use it in GitHub Desktop.
Canvas Code - Does not compile on Platformio - 202603131034
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Arduino.h> | |
| #include <FastLED.h> | |
| #include <FastLED_canvas.h> | |
| #define LED_PIN 12 | |
| #define WIDTH 16 | |
| #define HEIGHT 16 | |
| #define NUM_LEDS (WIDTH * HEIGHT) | |
| #define BRIGHTNESS 75 | |
| CRGB leds[NUM_LEDS]; | |
| // Create a canvas for drawing | |
| FastLED_Canvas canvas(WIDTH, HEIGHT, leds); | |
| // Colors | |
| CRGB color1 = CRGB::Red; | |
| CRGB color2 = CRGB::Blue; | |
| void setup() { | |
| FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS); | |
| FastLED.setBrightness(BRIGHTNESS); | |
| FastLED.clear(); | |
| FastLED.show(); | |
| } | |
| void loop() { | |
| // --- Draw Circle --- | |
| canvas.clear(); | |
| canvas.drawCircle(WIDTH/2, HEIGHT/2, 6, color1); // center, radius, color | |
| FastLED.show(); | |
| delay(500); | |
| // --- Clear --- | |
| canvas.clear(); | |
| FastLED.show(); | |
| delay(50); | |
| // --- Draw Square --- | |
| canvas.clear(); | |
| canvas.drawRect(3, 3, WIDTH-4, HEIGHT-4, color2); // x1,y1,x2,y2,color | |
| FastLED.show(); | |
| delay(500); | |
| // --- Clear --- | |
| canvas.clear(); | |
| FastLED.show(); | |
| delay(50); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment