uwezi icon

20210113_arduino_neopixel

uwezi | PRO | 01/13/21 09:34:01 PM UTC | 0 ⭐ | 1547 👁️ | Never ⏰ | []
Arduino |

620 B

|

None

|

0 👍

/

0 👎

#include <Arduino.h>
#include <FastLED.h>
 
#define LED_PIN     11
#define COLOR_ORDER GRB
#define CHIPSET     WS2811
#define NUM_LEDS    1
 
CRGB leds[NUM_LEDS];
 
void setup() 
{
  FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
 
uint8_t i=0;
uint8_t upp=1;
void loop() 
{
  if (upp)
  {
    if (i<255)
    {
      i++;
    }
    else
    {
      upp = 0;
    }
  }
  else
  {
    if (i>0)
    {
      i--;
    }
    else
    {
      upp = 1;
    }
  }
  
  leds[0].r = i; 
  leds[0].g = i; 
  leds[0].b = i; 
  FastLED.show(); 
  delay(4);
}

Comments