3dRyan Tap Tempo Led Code

Started by StevenMartin, February 14, 2022, 02:02:08 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

StevenMartin

3dRyan, apparently your inbox is full. Maybe you'll see this:  (possible help for the tap tempo LED code)

Actually here's a better (and now tested) example:

#include <FastLED.h>

#define NUM_LEDS 1
#define DATA_PIN 28
CRGB leds[NUM_LEDS];

byte TapLedNum = 0;

uint32_t tempoMillis = 500;
uint32_t tempo = 60000 / tempoMillis;

void blinkTapLed() {
  static uint32_t timeCapture;
  static bool blinkState;

  if ((millis() - timeCapture) >= tempoMillis / 2) {
    timeCapture = millis();
    blinkState = !blinkState;
    leds[TapLedNum] = CHSV(120, 255, (blinkState ? 255 : 0));
    FastLED.show();
  }
}

void setup() {
  FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
  Serial.begin(9600);
  Serial.print(tempo);
}

void loop() {
  blinkTapLed();
}