Commit 5fbab8aa authored by Tomáš Hübelbauer's avatar Tomáš Hübelbauer

Migrate to Arduino Micro and simplify code

parent afc4e836
{
"board": "arduino:avr:pro",
"configuration": "cpu=16MHzatmega328",
"port": "COM8",
"board": "arduino:avr:micro",
"port": "COM6",
"sketch": "index.ino"
}
\ No newline at end of file
#include "FastLED.h"
#define LED_PIN 4
#define LED_COUNT 90
#define COLOR_COUNT 4
volatile unsigned long ledIndex = 0;
volatile unsigned long colorIndex = 0;
volatile unsigned long index = 0;
CRGB leds[LED_COUNT];
void setup() {
FastLED.addLeds<WS2812B, 7, GRB>(leds, LED_COUNT);
FastLED.setBrightness(200);
pinMode(LED_BUILTIN, OUTPUT);
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, LED_COUNT);
FastLED.setBrightness(50);
}
void loop() {
switch (colorIndex) {
case 0: leds[ledIndex] = CRGB::Red; break;
case 1: leds[ledIndex] = CRGB::Orange; break;
case 2: leds[ledIndex] = CRGB::Red; break;
case 3: leds[ledIndex] = CRGB::Yellow; break;
}
if (ledIndex % 3 == 0) {
if (colorIndex == COLOR_COUNT - 1) {
colorIndex = 0;
} else {
colorIndex++;
}
digitalWrite(LED_BUILTIN, HIGH);
if (ledIndex % 2 == 0) {
leds[ledIndex] = CRGB::Red;
} else {
leds[ledIndex] = CRGB::Orange;
}
if (ledIndex == LED_COUNT - 1) {
......@@ -35,5 +30,6 @@ void loop() {
}
FastLED.show();
digitalWrite(LED_BUILTIN, LOW);
delay(10);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment