Shuyi’s week5 homework

include

define PIN 6

define NUM_LEDS 8

define BRIGHTNESS 50

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
// NEO_GRB Pixels are wired for GRB bitstream, correct if colors are swapped upon testing
// NEO_RGBW Pixels are wired for RGBW bitstream
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels)
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRBW + NEO_KHZ800);

void setup() {

strip.setBrightness(BRIGHTNESS);
strip.begin();
strip.show(); // Initialize all pixels to ‘off’
}

void loop() {

int a = random(0,30);

customFunction(strip.Color(a,0, 0),100);
customFunction(strip.Color(0,2a, 0),100); customFunction(strip.Color(0,0, 3a),100);
customFunction(strip.Color(4a,0, 0),100); customFunction(strip.Color(0,5a, 0),100);
customFunction(strip.Color(0,0, 6a),100); customFunction(strip.Color(7a,7a, 0),100); customFunction(strip.Color(8a,8a, 8a),100);

}

void customFunction(uint32_t c, uint8_t wait){
//for(uint16_t i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(random(1,8), c);
strip.show();
delay(wait);
//}
}

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s