CodeMonster
Member
So I'm using a common anode RGB LED. I didn't intend on using anode but I ordered the wrong ones. Whatever.... So I've got it wired up correctly and I'm able to get the correct colors I want. I'm just trying to blink on and off through a series of different colors. The problem is when the LED is supposed to be completely off. It's very dim white but not completely off. Has anyone run across this before?
I tried different RGB LED's including a common cathode LED I had. (I altered the wiring for cathode LED of course.)
Also, I tried it with an Arduino Uno and it worked perfectly. Is this possibly a difference between Ardunio and Teensy?
Here's the code:
int redPin = 5; // Red LED, connected to digital pin 3
int greenPin = 4; // Green LED, connected to digital pin 4
int bluePin = 3; // Blue LED, connected to digital pin 5
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
rgbOrange();
delay(1000);
rgbOff();
delay(1000);
rgbPurple();
delay(1000);
rgbOff();
delay(1000);
rgbYellow();
delay(1000);
rgbOff();
delay(1000);
}
void rgbOff()
{
analogWrite(redPin, 255); // Write current values to LED pins
analogWrite(greenPin, 255);
analogWrite(bluePin, 255);
}
// These color values are based on Common Anode RGB LED's, not Cathode so LOW = 1, HIGH = 0
void rgbOrange()
{
analogWrite(redPin, 0); // Write current values to LED pins
analogWrite(greenPin, 175);
analogWrite(bluePin, 255);
}
void rgbPurple()
{
analogWrite(redPin, 0); // Write current values to LED pins
analogWrite(greenPin, 255);
analogWrite(bluePin, 0);
}
void rgbYellow()
{
analogWrite(redPin, 0); // Write current values to LED pins
analogWrite(greenPin, 75);
analogWrite(bluePin, 255);
}

I tried different RGB LED's including a common cathode LED I had. (I altered the wiring for cathode LED of course.)
Also, I tried it with an Arduino Uno and it worked perfectly. Is this possibly a difference between Ardunio and Teensy?
Here's the code:
int redPin = 5; // Red LED, connected to digital pin 3
int greenPin = 4; // Green LED, connected to digital pin 4
int bluePin = 3; // Blue LED, connected to digital pin 5
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
rgbOrange();
delay(1000);
rgbOff();
delay(1000);
rgbPurple();
delay(1000);
rgbOff();
delay(1000);
rgbYellow();
delay(1000);
rgbOff();
delay(1000);
}
void rgbOff()
{
analogWrite(redPin, 255); // Write current values to LED pins
analogWrite(greenPin, 255);
analogWrite(bluePin, 255);
}
// These color values are based on Common Anode RGB LED's, not Cathode so LOW = 1, HIGH = 0
void rgbOrange()
{
analogWrite(redPin, 0); // Write current values to LED pins
analogWrite(greenPin, 175);
analogWrite(bluePin, 255);
}
void rgbPurple()
{
analogWrite(redPin, 0); // Write current values to LED pins
analogWrite(greenPin, 255);
analogWrite(bluePin, 0);
}
void rgbYellow()
{
analogWrite(redPin, 0); // Write current values to LED pins
analogWrite(greenPin, 75);
analogWrite(bluePin, 255);
}
