I am having a bit of trouble from what would seem to be simple
I should be past this and able to figure it out on my own but cannot so here I go with another First Grade problem
When I do the Lesson 3 tutorial not all the colors correspond, I have triple checked the 3 wires and still cannot get the proper color to names.
The only one is RED, I must be missing the obvious and apologize for the time someone will have to spend to help me
Red to Pin 11
Green to Pin 10
Blue to Pin 11
5v to Anode (example is grounded but not my issue)
First color in the sketch is supposed to be red and it is Aqua and the last of the 6 colors is Red ( I changed the delay to be sure of which is which)
What am I doing wrong
Also another proof is if I null all the colors except RED the LED is Aqua proving something is array
RGB Help Lesson 3
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: RGB Help Lesson 3
Sounds like you have a common cathode LED after all. Try grounding the cathode pin instead of connecting it to 5V
- mjpcarbon
- Posts: 436
- Joined: Fri Nov 29, 2013 8:57 pm
Re: RGB Help Lesson 3
I did then nothing works
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: RGB Help Lesson 3
Post a picture showing your wiring.
- mjpcarbon
- Posts: 436
- Joined: Fri Nov 29, 2013 8:57 pm
Re: RGB Help Lesson 3
keep in mind the sketch works but colors are incorrect
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: RGB Help Lesson 3
OK, so you're using a Common Anode LED. That means that everything is backwards from the sample code, which assumes Common Cathode. The tutorial needs to be updated somehow, because switching from CC to CA requires more than just switching one pin from GND to 5V. The color logic also needs to be inverted.
Try this code:
Try this code:
Code: Select all
/*
Adafruit Arduino - Lesson 3. RGB LED
*/
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
//uncomment this line if using a Common Anode LED
#define COMMON_ANODE
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}
void loop()
{
setColor(255, 0, 0); // red
delay(1000);
setColor(0, 255, 0); // green
delay(1000);
setColor(0, 0, 255); // blue
delay(1000);
setColor(255, 255, 0); // yellow
delay(1000);
setColor(80, 0, 80); // purple
delay(1000);
setColor(0, 255, 255); // aqua
delay(1000);
}
void setColor(int red, int green, int blue)
{
#ifdef COMMON_ANODE
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
#endif
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
- mjpcarbon
- Posts: 436
- Joined: Fri Nov 29, 2013 8:57 pm
Re: RGB Help Lesson 3
oooooh
I will do it this evening and report thank you
I will do it this evening and report thank you
- mjpcarbon
- Posts: 436
- Joined: Fri Nov 29, 2013 8:57 pm
Re: RGB Help Lesson 3
Still really doesnt work properly
I nulled all but red green blue yet it blinks red blue green ?
Also confusing is the fact it only works with 5v ?
Wow something so simple is really confusing
However if you rename Green to pin9 and Blue to 10 it works right.
I nulled all but red green blue yet it blinks red blue green ?
Also confusing is the fact it only works with 5v ?
Wow something so simple is really confusing
However if you rename Green to pin9 and Blue to 10 it works right.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: RGB Help Lesson 3
Yeah, RGB LEDs can be confusing. But at least you got it going, right?
- mjpcarbon
- Posts: 436
- Joined: Fri Nov 29, 2013 8:57 pm
Re: RGB Help Lesson 3
Yes, it works great so now I have a related question.
If I were to use it in a temp situation for example
If the sensor reached 100 degrees it would lite RED
Would the code read " ifpin?=_(setcolorRED)or something along those lines ?
If I were to use it in a temp situation for example
If the sensor reached 100 degrees it would lite RED
Would the code read " ifpin?=_(setcolorRED)or something along those lines ?
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: RGB Help Lesson 3
You would do something along these lines:
Code: Select all
temperature = <call whatever reads the temperature here>;
if (100 <= temperature)
{
setColor(255, 0, 0); //red
}
else
{
setColor(0, 0, 255); /blue
}
- mjpcarbon
- Posts: 436
- Joined: Fri Nov 29, 2013 8:57 pm
Re: RGB Help Lesson 3
I am now trying to mix the rgb sketch with the tmp06 sketch and I am getting a compile error that states
setColor was not declared in this scope.
So as I look at the Lesson 3 sketch I dont see where 'setColor' was ever declared ?
setColor was not declared in this scope.
So as I look at the Lesson 3 sketch I dont see where 'setColor' was ever declared ?
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: RGB Help Lesson 3
setColor is declared below loop() in the lesson 3 sketch:
Code: Select all
void setColor(int red, int green, int blue)
{
#ifdef COMMON_ANODE
red = 255 - red;
green = 255 - green;
blue = 255 - blue;
#endif
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
- mjpcarbon
- Posts: 436
- Joined: Fri Nov 29, 2013 8:57 pm
Re: RGB Help Lesson 3
I give up on this one more error messages than I can even share,
So I decided to do it the hard way with the RGB and it works like I want it to, then I wanted to blink one of the colors.
I thought I could add delay(1000); below the LOW line and guess what, it doesnt blink
I have tried putting the delay in a couple places but am once again missing it.
So I decided to do it the hard way with the RGB and it works like I want it to, then I wanted to blink one of the colors.
I thought I could add delay(1000); below the LOW line and guess what, it doesnt blink
I have tried putting the delay in a couple places but am once again missing it.
Code: Select all
//TMP36 Pin Variables
int temperaturePin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade
int ledPin = 9; // LED connected to digital pin 13 Green LED
int ledPin2 = 11; // LED connected to digital pin 12 Red LED
/*
* setup() - this function runs once when you turn your Arduino on
* We initialize the serial connection with the computer
*/
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(ledPin2, OUTPUT);
Serial.begin(9600); //Start the serial connection with the copmuter
//to view the result open the serial monitor
//last button beneath the file bar (looks like a box with an antenae)
}
void loop() // run over and over again
{
float temperature = getVoltage(temperaturePin); //getting the voltage reading from the temperature sensor
temperature = (((temperature - .5) * 100)*1.8) + 32; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((volatge - 500mV) times 100)
Serial.println(temperature); //printing the result
Serial.println(" Fahrenheit");
delay(1000); //waiting a second
if (temperature > 75) digitalWrite(11,HIGH);
if (temperature < 75) digitalWrite(11,LOW);
if (temperature > 75) digitalWrite(9,LOW);
if (temperature < 75) digitalWrite(9,HIGH);
}
/*
* getVoltage() - returns the voltage on the analog input defined by
* pin
*/
float getVoltage(int pin){
return (analogRead(pin) * .004882814); //converting from a 0 to 1023 digital range
// to 0 to 5 volts (each 1 reading equals ~ 5 millivolts
}
Please be positive and constructive with your questions and comments.