how to draw a flowchart for showSpectrum & showRGB
how draw flowchart showspectrum & showrgb
can show me start before can contiune
void showspectrum()
{
int x;
for(x = 0; x < 768; x++)
{
showrgb(x);
delay(10);
}
}
void showrgb(int color)
{
int redintensity;
int greenintensity;
int blueintensity;
if (color <= 255) // zone 1
{
redintensity = 255 - color; // redgoes on off
greenintensity = color; // green goes fromoff on
blueintensity = 0; // blue off
}
else if (color <= 511) //zone 2
{
redintensity = 0; // red off
greenintensity = 255 - (color - 256); // green on off
blueintensity = (color - 256); // blue off on
}
else // color >= 512 // zone3
{
redintensity = (color - 512); // red if off on
greenintensity = 0; // green off
blueintensity = 255 - (color - 512); // blue off on
}
analogwrite(red_pin, redintensity);
analogwrite(green_pin, greenintensity);
analogwrite(blue_pin, blueintensity);
}
can show me start before can contiune
void showspectrum()
{
int x;
for(x = 0; x < 768; x++)
{
showrgb(x);
delay(10);
}
}
void showrgb(int color)
{
int redintensity;
int greenintensity;
int blueintensity;
if (color <= 255) // zone 1
{
redintensity = 255 - color; // redgoes on off
greenintensity = color; // green goes fromoff on
blueintensity = 0; // blue off
}
else if (color <= 511) //zone 2
{
redintensity = 0; // red off
greenintensity = 255 - (color - 256); // green on off
blueintensity = (color - 256); // blue off on
}
else // color >= 512 // zone3
{
redintensity = (color - 512); // red if off on
greenintensity = 0; // green off
blueintensity = 255 - (color - 512); // blue off on
}
analogwrite(red_pin, redintensity);
analogwrite(green_pin, greenintensity);
analogwrite(blue_pin, blueintensity);
}
what need understand?
the code has value varying between 0 , 767
when value between 0 , 255 there inversely correlated mix between red , green full red , no green full green , no red
then 256 511 green , blue mixed - go full green (so continuation of previous color) full blue
then 512 767 mix blue , red full blue full red
this pretty crude because human eyes not perceive r, g or b same way inverse correlation of mix not deliver superbly looking rainbow spectrum.
also make sure wire rgb led right way current limiting resistors, colors don't have same forward voltage still send 0 5v each pin (blue , green have same specs same resistor, red needs higher resistor). remember max current ability of arduino when defining resistor values.
the code has value varying between 0 , 767
when value between 0 , 255 there inversely correlated mix between red , green full red , no green full green , no red
then 256 511 green , blue mixed - go full green (so continuation of previous color) full blue
then 512 767 mix blue , red full blue full red
this pretty crude because human eyes not perceive r, g or b same way inverse correlation of mix not deliver superbly looking rainbow spectrum.
also make sure wire rgb led right way current limiting resistors, colors don't have same forward voltage still send 0 5v each pin (blue , green have same specs same resistor, red needs higher resistor). remember max current ability of arduino when defining resistor values.
Arduino Forum > Using Arduino > Programming Questions > how to draw a flowchart for showSpectrum & showRGB
arduino
Comments
Post a Comment