Created
April 29, 2022 03:34
-
-
Save zamfi/225919bc1b76a9956f27d39737f69deb to your computer and use it in GitHub Desktop.
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
#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