0
Offline
Newbie
Karma: 0
Posts: 34
Arduino rocks
|
 |
« Reply #30 on: September 17, 2009, 04:58:59 pm » |
ok, I got it now. How do you mke it so on post #19 the code makes it light only one color and not change through them?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #31 on: September 17, 2009, 05:14:26 pm » |
By using the code in post 26. Or if not the code the idea.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 34
Arduino rocks
|
 |
« Reply #32 on: September 17, 2009, 08:06:49 pm » |
yeah but almost all of the colors made by that code are white and the blue value is always 90-95
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #33 on: September 18, 2009, 02:14:45 am » |
Yes they will be, that's the nature of random numbers. That's why I offered the advice in reply #20.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 34
Arduino rocks
|
 |
« Reply #34 on: September 18, 2009, 07:51:35 pm » |
How do you make the code in past 19 so it recognizes values?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #35 on: September 21, 2009, 05:41:13 am » |
What do you mean by recognizes values Do you mean it accepts values over the serial input from the terminal or processing? If so this thread has some clues:- http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1252747698/all
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 34
Arduino rocks
|
 |
« Reply #36 on: September 21, 2009, 04:59:20 pm » |
I mean I want it to know how much the green is shining and same for all the other colors by using the serial monitor. I did it before, but the colors were not random enough. I want to do it with the code in post #19
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #37 on: September 21, 2009, 05:10:31 pm » |
You already know. This bit of code:- void RGBCommonLED::updateLED(){ analogWrite(this->pins[0], rgb[0]); analogWrite(this->pins[1], rgb[1]); analogWrite(this->pins[2], rgb[2]); }
Writes the RGB values out to the LED so the rgb[] array has the values you want in them. Am I missing something here?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 34
Arduino rocks
|
 |
« Reply #38 on: September 21, 2009, 05:39:01 pm » |
so what do I put when I write:
Serial.Print("[glow] [/glow], DEC") in the loop?
|
|
|
|
« Last Edit: September 21, 2009, 05:39:21 pm by ikestarm »
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #39 on: September 21, 2009, 06:47:27 pm » |
Serial.print(" R - "); Serial.print(rgb[0] , DEC); Serial.print(" G - "); Serial.print(rgb[1] , DEC); Serial.print(" B - "); Serial.println(rgb[2] , DEC);
|
|
|
|
« Last Edit: September 22, 2009, 04:16:55 am by Grumpy_Mike »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 34
Arduino rocks
|
 |
« Reply #40 on: September 21, 2009, 07:10:45 pm » |
I know I'm doing something really stupid right now, but where and how do I place that in the code? It keeps saying: expected constructor, destructor, or conversion type before '.' token
And it says "rgb[0] was not declared in this scope"
|
|
|
|
« Last Edit: September 21, 2009, 07:15:09 pm by ikestarm »
|
Logged
|
|
|
|
|
Global Moderator
UK
Offline
Brattain Member
Karma: 143
Posts: 19368
I don't think you connected the grounds, Dave.
|
 |
« Reply #41 on: September 22, 2009, 01:44:28 am » |
We're working blind here - can you post your code and tell us what it is you want to do?
If you don't have something like "byte rgb [3];" declared somewhere in scope, your code won't compile.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #42 on: September 22, 2009, 04:12:10 am » |
Place the print code after you have set the values so for example you could put it at the end of the void RGBCommonLED::updateLED(){ definition.
OR
If you want to be able to print from anywhere then move the definition of the rgb[] array so that it is global. That is move it to outside a function to the start of the sketch. Then you can put the print statements anywhere you like,
P.S. Forgot to include a semicolon at the end of all the print lines, now corrected.
|
|
|
|
« Last Edit: September 22, 2009, 04:18:02 am by Grumpy_Mike »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 34
Arduino rocks
|
 |
« Reply #43 on: September 22, 2009, 07:45:15 pm » |
Thanks it's working great but how do I change this part: void setup() { Serial.begin(9600); randomSeed(analogRead(0)); testRGB(); }
void testRGB(){ led1.setRGB(255,0,0); led1.updateLED(); delay(500); led1.setRGB(0,255,0); led1.updateLED(); delay(500); led1.setRGB(0,0,255); led1.updateLED(); delay(2000); return;
}
void loop() { led1.setRandomHue(); led1.setSat(255); led1.setVal(255); led1.updateLED(); delay(3000); led1.setRandomColor(); led1.updateLED(); delay(1000); return;
} so that there is no "test" and it only show one color, not changing the color?
|
|
|
|
« Last Edit: September 22, 2009, 07:45:30 pm by ikestarm »
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 299
Posts: 26024
Solder is electric glue
|
 |
« Reply #44 on: September 23, 2009, 12:59:23 am » |
so that there is no "test" and it only show one color, not changing the color? Take everything in the loop() function and put it in the setup() function. The loop() function will be empty but you still need it. Also there is no need to have a return statement at the end of a function.
|
|
|
|
|
Logged
|
|
|
|
|
|