Skip to content

Instantly share code, notes, and snippets.

@zachflower
Last active February 19, 2024 09:34
Show Gist options
  • Save zachflower/79df9ed5ca398264d3b6 to your computer and use it in GitHub Desktop.
Save zachflower/79df9ed5ca398264d3b6 to your computer and use it in GitHub Desktop.
Smooth RGB LED Color Transitions (Arduino)
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);
}
@PseudoCoding
Copy link

That's really cool! I cant believe they just leave it open to connect yet their app has so many issues connecting to it. Even my SwitchPro 9100 has at least a password locking it from any random device connecting to it. I'm going to try and connect to it when I have some time and see what I can do to it. More controllers would be cool, but I first want to get this one working as its pretty much useless to me right now. I reached out to Morimoto who said they have plans to update the app early this year but I'm not holding my breath. I also reached out to other companies with similar products to swap it but they needed more custom wiring than I would like to do since everything I have in my headlights is Morimoto. If I get in and make any progress I'd be more than willing to try to help where I can.

@tonton81
Copy link

tonton81 commented Jan 26, 2021

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

@PseudoCoding
Copy link

PseudoCoding commented Jan 26, 2021

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?

@tonton81
Copy link

tonton81 commented Jan 27, 2021

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