Skip to content

Instantly share code, notes, and snippets.

@zamfi
Created April 29, 2022 03:34
Show Gist options
  • Save zamfi/225919bc1b76a9956f27d39737f69deb to your computer and use it in GitHub Desktop.
Save zamfi/225919bc1b76a9956f27d39737f69deb to your computer and use it in GitHub Desktop.
#include <Adafruit_DotStar.h>
// There is only one pixel on the board
#define NUMPIXELS 1
//Use these pin definitions for the ItsyBitsy M4
#define DATAPIN 7
#define CLOCKPIN 8
Adafruit_DotStar strip(NUMPIXELS, DATAPIN, CLOCKPIN, DOTSTAR_BRG);
void setup() {
Serial.begin(9600);
strip.begin(); // Initialize pins for output
strip.setBrightness(80);
strip.show(); // Turn all LEDs off ASAP
}
String lastLetter = "R";
void loop() {
if (Serial && Serial.available()) {
lastLetter = Serial.readStringUntil('\n');
lastLetter.trim();
}
if (lastLetter == "G") {
strip.setBrightness(80);
strip.setPixelColor(0, strip.gamma32(strip.ColorHSV(0)));
strip.show();
} else if (lastLetter == "R") {
strip.setBrightness(80);
strip.setPixelColor(0, strip.gamma32(strip.ColorHSV(21846)));
strip.show();
} else {
strip.setBrightness(0);
strip.show();
}
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment