Code Monkey home page Code Monkey logo

fastled-basics's People

Contributors

s-marley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fastled-basics's Issues

Button and timer mixed

#include <FastLED.h>
#include <OneButton.h>

#define NUM_LEDS 10
#define LED_PIN 7
#define BTN_PIN 6

CRGB leds[NUM_LEDS];

uint8_t patternCounter = 0;

// Push button connected between pin 7 and GND (no resistor required)
OneButton btn = OneButton(BTN_PIN, true, true);

void setup() {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(255);
Serial.begin(57600);

btn.attachClick(nextPattern);
}

void loop() {

switch (patternCounter) {
case 0:
movingDots();
break;
case 1:
rainbowBeat();
break;
case 2:
redWhiteBlue();
break;
}

EVERY_N_SECONDS(10)
{
nextPattern();
}

FastLED.show();
btn.tick();
}

void nextPattern() {
patternCounter = (patternCounter + 1) % 3; // Change the number after the % to the number of patterns you have
}

//------- Put your patterns below -------//

void movingDots() {

uint16_t posBeat = beatsin16(30, 0, NUM_LEDS - 1, 0, 0);
uint16_t posBeat2 = beatsin16(60, 0, NUM_LEDS - 1, 0, 0);

uint16_t posBeat3 = beatsin16(30, 0, NUM_LEDS - 1, 0, 32767);
uint16_t posBeat4 = beatsin16(60, 0, NUM_LEDS - 1, 0, 32767);

// Wave for LED color
uint8_t colBeat = beatsin8(45, 0, 255, 0, 0);

leds[(posBeat + posBeat2) / 2] = CHSV(colBeat, 255, 255);
leds[(posBeat3 + posBeat4) / 2] = CHSV(colBeat, 255, 255);

fadeToBlackBy(leds, NUM_LEDS, 10);
}

void rainbowBeat() {

uint16_t beatA = beatsin16(30, 0, 255);
uint16_t beatB = beatsin16(20, 0, 255);
fill_rainbow(leds, NUM_LEDS, (beatA + beatB) / 2, 8);
}

void redWhiteBlue() {

uint16_t sinBeat = beatsin16(30, 0, NUM_LEDS - 1, 0, 0);
uint16_t sinBeat2 = beatsin16(30, 0, NUM_LEDS - 1, 0, 21845);
uint16_t sinBeat3 = beatsin16(30, 0, NUM_LEDS - 1, 0, 43690);

leds[sinBeat] = CRGB::Blue;
leds[sinBeat2] = CRGB::Red;
leds[sinBeat3] = CRGB::White;

fadeToBlackBy(leds, NUM_LEDS, 10);
}

This is code for mixing timing change and button press. Change the time or add a physical 2 state switch for checking on-off.

Sorry, I don't know how to use git.

Free FastLED simulator ๐Ÿ˜€

Hello There

Good day

I have compiled a collection of FastLED simulations (all based on your examples provided)
I would like to request you to add the wokwi simulator link to your readme page if you find this simulator helpful for your viewers.

if you have any suggestions or feedback, please feel free to suggest.

Thanks in Advance!

https://wokwi.com/arduino/projects/287903705030722060
https://wokwi.com/arduino/projects/287938818561016332
https://wokwi.com/arduino/projects/287939551461114380
https://wokwi.com/arduino/projects/287940145420698120
https://wokwi.com/arduino/projects/288329771683676685
https://wokwi.com/arduino/projects/288331607751787020
https://wokwi.com/arduino/projects/288332130035958280

Regards
Matititam

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.