4. CODE SOME PIXELS!
The Pixelblaze is programmed using JavaScript,
and whats great about it is that there are a
whole bunch of existing pieces of code you can
modify. I downloaded the FireFlies example from
electromage.com/patterns, opened it in the
Pixelblaze interface, and began to modify some
of the variables that were available to better
understand how to control the pattern (Figure
S
).
The effect I wanted was that when the rain
hits the umbrella, there should be a sparkle
of randomly generated firefly light. So I knew
my pattern had to be bright and fast. I played
with variables like maxSpeed, decay, and
sparkSaturation until I liked my sparkle effect.
Then, I added sensor input. I wanted the Y axis
of the accelerometer to modify the colors, and the
analog 0 pin to read the piezo mic data. To do this,
I added these two lines at the top which create
arrays that hold the input data. These are built
into the Pixelblaze code and will automatically
grab the variable data from the accelerometer
and the input pins.
export var analogInputs = array(5)
export var accelerometer = array(3)
Next I modified the render function, which is
responsible for displaying the pixels. I added an
if() statement which checks the value of analog
pin 0 by checking the array in position 0 with
analogInputs[0] (Figure
T
). I set a threshold
value of 0.3, but this might be different for you.
You can monitor the value of input variables on
the right-hand side of the interface, so I checked
to seewhat the value was when I tapped on the
piezo to simulate rain.
I also used HSV (hue, saturation, vibrance)
instead of RGB (red, green, blue) values to
manipulate the colors, which made it easier to
use the accelerometer[0] value to change the
color as the user moves the umbrella.
The resulting code shows a sparkle only when
the piezo picks up a sound, and the hue of the
sparkle is based on the umbrella’s position! You
can grab my code, and modify it as you wish, from
github.com/LeeRobot/accel_umbrell/blob/main/
pixels.js.
More about Pixelblaze
Read A Perfect Circle” on page 28
Sew your own Pixelblaze Pillows, page 48
2022 Boards Guide, included with this issue
Q R
S
T
Dushan Milic, Lee Wilkins
75
make.co
M83_070-75_SquishyLee_F1.indd 75M83_070-75_SquishyLee_F1.indd 75 10/10/22 3:51 PM10/10/22 3:51 PM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.191.22