Class 6

Ying Gao

Taiknam Hat (2008)

Sewable Neopixels

Neopixel Programming:

Include Library
#include <Adafruit_NeoPixel.h>

Declare Variables
Adafruit_NeoPixel strip = Adafruit_NeoPixel(number of pixels, pin number on board, NEO_GRB + NEO_KHZ800);

strip.begin();; // Initialize all pixels to ‘off’

setPixelColor(pixel number, R, G, B); //sets a certain pixel number to a defined color, RGB
setBrightness(value); //sets brightness for all pixels; //use this every time you want to refresh the pixels

Working with Data:


//if it is dark
if(lightSensorValue < 200) {
//turn LED on
digitalWrite(LEDpin, HIGH);
//if it is light
else {
//turn LED off
digitialWrite(LEDpin, LOW);

Multiple Thresholds

if (condition) {
do this
} else if (2nd condition) {
do something else
} else {
do the last thing if it’s neither of the above


map(value, fromLow, from Hight, toLow, toHigh);



constrain(lightValue, 0, 255);


Galvanic Skin Conductance Response


In Class Experiment: Work with a servo motor, muscle wire or DC motor to create an interesting motion with fabric.

Here is an example for using a servo motor:

If you are using a servo with your flora, the red wire should go to VBATT, the brown wire to GND, and the yellow or orange wire to one of your analog output pins (pin 9 if you want to stick with the variables in the example code). The example code can also be found in the Examples files in the arduino software.

The example code sweeps the motor from 0 to 180 degrees and back again. Attach one of the arms to your motor, upload the code and see what motion you can create. Try changing the delay times to create a slower sweep, or sweep to different angles.

Servo motors have different ranges. Some range from 0 to 90 degrees, some from -90 to 90 degrees (for a total of 180 degrees), some from 0 to 180 degrees, and some go from 0 to 360. If you are trying to tell your motor to go to an angle it cannot accommodate, it will make a jerking motion and/or strange sound. You can look up the datasheet for your motor online to find out more about its properties.

Once you have your motor turning, try attaching fabric to your motor arms with thread in order to get some interesting motion effects. Feel free to get in touch if you have any problems or questions.

Here are a few links for inspiration:

Max MSP –

Serial Audio Mixer Max Patch – copy and past text into a new patcher.