Last active
August 21, 2024 23:06
-
-
Save zachflower/79df9ed5ca398264d3b6 to your computer and use it in GitHub Desktop.
Smooth RGB LED Color Transitions (Arduino)
This file contains hidden or 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
int redPin = 11; | |
int greenPin = 10; | |
int bluePin = 9; | |
int r = 0; | |
int g = 0; | |
int b = 0; | |
void setup() { | |
pinMode(redPin, OUTPUT); | |
pinMode(greenPin, OUTPUT); | |
pinMode(bluePin, OUTPUT); | |
} | |
void loop() { | |
setColor(255, 0, 0); // red | |
setColor(0, 255, 0); // green | |
setColor(0, 0, 255); // blue | |
setColor(255, 255, 0); // yellow | |
setColor(80, 0, 80); // purple | |
setColor(0, 255, 255); // aqua | |
} | |
void setColor(int red, int green, int blue) { | |
while ( r != red || g != green || b != blue ) { | |
if ( r < red ) r += 1; | |
if ( r > red ) r -= 1; | |
if ( g < green ) g += 1; | |
if ( g > green ) g -= 1; | |
if ( b < blue ) b += 1; | |
if ( b > blue ) b -= 1; | |
_setColor(); | |
delay(10); | |
} | |
} | |
void _setColor() { | |
analogWrite(redPin, r); | |
analogWrite(greenPin, g); | |
analogWrite(bluePin, b); | |
} |
Oh interesting! So that's why their app says to place the phone on the XBT. Since my phone has been unable to connect (all app permissions enabled) I'm assuming the XBT is having issues with RSSI and my phones (all android). What's the range look like for connecting from the ESP32? Also does the XBT just emit a bluetooth signal anytime it has power?
it broadcasts itself if there are no connections to it. example, if i unplug the esp32, the phone will "eventually" pick up the XBT, i say eventually because it may take up to 15 seconds with the app, the esp32 connects in less than a second hahaha
the XBT range should be normal bluetooth range, considering people install the XBT in their engine bays amd use a phone app, the ESP32 should be fine
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yeah their app "security" requires a high RSSI to make sure you have physical access to surface of the XBT, however, RSSI is not important, when I detect an XBT I can just connect to it's MAC address (which is static) and it connects in less than a second and runs for several days without issues