EasyManua.ls Logo

Thames & Kosmos Code Gamer - SOFTWARE LIBRARIES

Thames & Kosmos Code Gamer
66 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
void setup() {
// There is nothing to do here.
}
void loop() {
// 50 is a good brightness value.
// The highest brightness level is 255.
// It can be a bit blinding though!
brightness = 50;
// r e d
red = 255;
green = 0;
blue = 0;
pixel.setColor(red, green, blue, brightness);
delay(5 00);
// g r e e n
red = 0;
green = 255;
blue = 0;
pixel.setColor(red, green, blue, brightness);
delay(5 00);
// bl u e
red = 0;
green = 0;
blue = 255;
pixel.setColor(red, green, blue, brightness);
delay(5 00);
// p u r pl e
red = 255;
green = 0;
blue = 255;
pixel.setColor(red, green, blue, brightness);
delay(5 00);
// t u r q u oi s e
red = 0;
green = 255;
blue = 255;
pixel.setColor(red, green, blue, brightness);
delay(5 00);
// y ell o w
red = 255;
green = 255;
blue = 0;
pixel.setColor(red, green, blue, brightness);
delay(5 00);
</>
In
s e tu p()
there will be nothing for you to do this time,
since the program that you will be linking with the
#include
instruction will already be handling it for you.
In the main loop, the first thing to do is set the brightness:
brightness = 50;
. The highest level of brightness is set
with a value of 255; with 0, the NeoPixel remains dark.
Then the various colors are produced one after the other.
To do that, you will be assigning the
red
,
green
and
blue
variables different values.
The line
pixel.setColor(red, green, blue, brightness);
is
the decisive factor for each color. First of all, it tells the
NeoPixel that it is supposed to display a new color! In
these instructions,
setColor()
is a so-called method of
the
pixel
object. To invoke a method of an object, the
method’s name is attached to the name of the object
separated by a period.
With
delay(5 0 0);
you will make your KosmoDuino wait
half a second before adjusting the net color.
The NeoPixel
shines in
various colors

CodeGamer
CodeGamer manual inside english.indd 19 7/19/16 12:32 PM