IMG_6316.JPG

itp

Homemade Hardware Week 5: Breadboarding & Eagle Diagrams.

 

To test the interaction for my final project, I used a pre-made Adafruit neopixel component: the Circuit Playground Express (thanks Nick for lending it to me!)

Eagle schematic for the custom USB

Eagle schematic for the custom USB

Using the excellent Adafruit documentation, I set out to modify the “bike light” code to be photo-reactive. I utilized the built in photocell on the circuit playground express. Using the serial plotter, I took levels of brightness and darkness to inform the chip of when to turn on (see video above)

You can the code below.

#include <Adafruit_CircuitPlayground.h>

#define ROTATION_RATE 50 // lower is faster

int value;

// Define 10 colors here.

// Must be 10 entries.

// Use 0x000000 if you want a blank space.

uint32_t colors[] = {

0xFF0000,

0xFF5500,

0xFFFF00,

0x00FF00,

0x0000FF,

0xFF00FF,

0x000000,

0x000000,

0x000000,

0x000000

};

int colorIndex;

int startIndex;

void setup() {

CircuitPlayground.begin();

// Make it bright!

CircuitPlayground.setBrightness(30);

// Start at the beginning

startIndex = 0;

}

void loop() {

value = CircuitPlayground.lightSensor();

// Turn off all the NeoPixels

CircuitPlayground.clearPixels();

if (value < 40) {

// Loop through and set pixels

colorIndex = startIndex;

for (int pixel=0; pixel<10; pixel++) {

CircuitPlayground.setPixelColor(pixel, colors[colorIndex]);

colorIndex++;

if (colorIndex > 9) colorIndex = 0;

}

// Increment start index into color array

startIndex++;

// Check value and reset if necessary

if (startIndex > 9) startIndex = 0;

// Wait a little bit so we don't spin too fast

delay(ROTATION_RATE);}

}

 
Caroline NeelComment