Hey guys. I just got my rainbowduino in and have started coding for it. I can make some basic programs and outputs and I am trying to make my programs are a little more complicated. I am trying to make a program where squares radiate from the center of the led matrix, and they cycle through the colors at different intervals, so it appears as if it is radiating from the center. The problem I am having is that I am converting the RGB number to HEX and storing it in a string, however the Rb.fillCircle command does not like the fact that there is a string where the color code should be.
Rb.fillRectangle(0, 0, 7, 7, random(0xFFFFFF)); // draw a filled rectangle line from (0,0) of length and width 7 pixels
delay(1000);
Rb.blankDisplay();
When r is non-zero, how do you propose to store (65536 * r)+ into a variable that can hold values in the range -32768 to 32767? There is a reason that the function expects an unsigned long.
#include <Rainbowduino.h>
void setup()
{
Rb.init(); //initialize Rainbowduino driver
}
int Delay=10,intensity=255;
int r=0,g=0,b=intensity,x=0,y=0,RGB=0;
void loop()
{
while (r<intensity)
{
RGB=((r*65536)+(g*256)+b);
String colorString=String(RGB, HEX);
Rb.fillRectangle(3,3,2,2,255,124,132);
r++;
b--;
delay(Delay);
}
}
I am assuming that's what you meant when you wanted me to input RGB. This is the error I get below. If I just input the variable RGB it just fades blue.
sketch_nov03b.ino: In function 'void loop()':
sketch_nov03b:16: error: no matching function for call to 'Rainbowduino::fillRectangle(int, int, int, int, int, int, int)'
C:\Users\Ryan\Documents\Arduino\libraries\Rainbowduino/Rainbowduino.h:80: note: candidates are: void Rainbowduino::fillRectangle(unsigned int, unsigned int, unsigned int, unsigned int, uint32_t)
Sorry, but what is an unsigned long? I am relatively new to coding and arduino, and there is very little documentation on the rainbowduino.
Surgikill:
I am assuming that's what you meant when you wanted me to input RGB. This is the error I get below. If I just input the variable RGB it just fades blue.
No. First GET RID OF THE STRING. You don't need it.
What I meant was to put RGB in the statement, like Rb.fillRectangle(3,3,2,2,RGB);, but I also mentioned that it depends on what data type RGB is. It MUST be the data type specifired for the fillRectangle() function, which is an unsigned long.
Try this...
At the top of your code, just above setup(), place this..
An unsigned long is a 32 bit integer that cannot be a negative number. Data types are very important, and you need to learn what each one is, as well as learning what data tpes each function you use will take.