Created
June 24, 2020 08:08
-
-
Save IdrisCytron/e1e6a5f02ba83da60c8cd46c4e4e260f to your computer and use it in GitHub Desktop.
Controlling built-in WS2812B RGB LED on Cucumber board.
This file contains 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
/* | |
Tutorial: Program ESP32-S2 Using Arduino IDE (Unofficial) | |
Board: ESP32S2 (Cucumber from Gravitech) | |
External libraries: | |
- Adafruit NeoPixel V1.5.0 (Manager) | |
*/ | |
#include <Adafruit_NeoPixel.h> | |
#define PIN 18 | |
#define NUMPIXELS 1 | |
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); | |
enum {NONE, RED, GREEN, BLUE}; | |
int ledColor = NONE; | |
void setup() | |
{ | |
pixels.begin(); | |
} | |
void loop() | |
{ | |
switch (ledColor) { | |
case NONE: | |
pixels.setPixelColor(0, pixels.Color(0, 0, 0)); | |
pixels.show(); | |
break; | |
case RED: | |
pixels.setPixelColor(0, pixels.Color(20, 0, 0)); | |
pixels.show(); | |
break; | |
case GREEN: | |
pixels.setPixelColor(0, pixels.Color(0, 20, 0)); | |
pixels.show(); | |
break; | |
case BLUE: | |
pixels.setPixelColor(0, pixels.Color(0, 0, 20)); | |
pixels.show(); | |
break; | |
default: | |
break; | |
} | |
ledColor++; | |
if (ledColor == 4) { | |
ledColor = NONE; | |
} | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment