First Animation

Here is the first piece of code for the start-up and shutdown animations for the rear light. I have tried to add code to control which pixels in the string will illuminate, but it’s kinda hacky. The lights turn on one way, and off in the other direction. Perhaps someone could guide me on how to “improve” this implementation.

This code assumes that the string of lights is connected to PIN 9.

#include <Adafruit_NeoPixel.h>
#define PIN 9
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// put your main code here, to run repeatedly:
lightStart(135,0,0,0,16); // Red Value, Green Value, Blue Value, Start From Pixel, End At Pixel
delay(5000);
lightStop(0,0,0,0,16); // Red Value, Green Value, Blue Value, Start From Pixel, End At Pixel
delay(5000);
}
void lightStart(uint32_t r, uint8_t g,uint8_t b,uint8_t s, uint8_t m ) {
for(uint16_t i=s; i<m; i++) {
strip.setPixelColor(i,r,g,b);
strip.show();
delay(50);
}
}
void lightStop(uint32_t r, uint8_t g,uint8_t b,uint8_t s, uint8_t m ) {
for(uint16_t i=m; i>s; i--) {
strip.setPixelColor(i,r,g,b);
strip.show();
delay(50);
}
strip.setPixelColor(s,r,g,b); // Hack to work with value 0
strip.show();
delay(50);
}

Again, this is built on the Adafruit NeoPixel Library, which is required to make this sketch work.

Testing Hardware

The time has come where we need to test all the hardware we have bought to this point.

I have modified some basic test source files to test the WS2812 LEDs, the 4×3 Matrix Keypad and the Arduino Uno
To test the keypad, use the following code.

/*  Keypadtest.pde
*
*  Demonstrate the simplest use of the  keypad library.
*
*  The first step is to connect your keypad to the
*  Arduino  using the pin numbers listed below in
*  rowPins[] and colPins[]. If you want to use different
*  pins then  you  can  change  the  numbers below to
*  match your setup.
*
*/
#include <Keypad.h>
const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'A','0','B'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 8, 7, 6, 5 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 4, 3, 2 }; 
// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
#define ledpin 14
void setup()
{
pinMode(ledpin,OUTPUT);
digitalWrite(ledpin, HIGH);
Serial.begin(9600);
}
void loop()
{
char key = kpd.getKey();
if(key)  // Check for a valid key.
{
switch (key)
{
case '*':
digitalWrite(ledpin, LOW);
break;
case '#':
digitalWrite(ledpin, HIGH);
break;
default:
Serial.println(key);
}
}
}

This is based on the standard Keypad Test Example File. This assumes that PIN 1 (onwards) from the Matrix is connected to PIN 2 (onwards) on the arduino. Pressing keys on the keypad will send data to the serial monitor in the arduino console and cause an LED to flash.

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
#define PIN 6
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.
void setup() {
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// Some example procedures showing how to display to the pixels:
colorWipe(strip.Color(153, 32, 153), 500); // pink-white
colorWipe(strip.Color(153, 153, 153), 500); // white
colorWipe(strip.Color(153, 32, 153), 500); // pink-white
colorWipe(strip.Color(1, 0, 0), 25); // Red
colorWipe(strip.Color(0, 1, 0), 25); // Green
colorWipe(strip.Color(0, 0, 1), 25); // Blue
colorWipe(strip.Color(10, 0, 0), 25); // Red
colorWipe(strip.Color(0, 10, 0), 25); // Green
colorWipe(strip.Color(0, 0, 10), 25); // Blue
colorWipe(strip.Color(25, 0, 0), 25); // Red
colorWipe(strip.Color(0, 25, 0), 25); // Green
colorWipe(strip.Color(0, 0, 25), 25); // Blue
colorWipe(strip.Color(50, 0, 0), 25); // Red
colorWipe(strip.Color(0, 50, 0), 25); // Green
colorWipe(strip.Color(0, 0, 50), 25); // Blue
colorWipe(strip.Color(100, 0, 0), 25); // Red
colorWipe(strip.Color(0, 100, 0), 25); // Green
colorWipe(strip.Color(0, 0, 100), 25); // Blue
colorWipe(strip.Color(153, 0, 0), 25); // Red
colorWipe(strip.Color(0, 153, 0), 25); // Green
colorWipe(strip.Color(0, 0, 153), 25); // Blue
colorWipe(strip.Color(200, 0, 0), 25); // Red
colorWipe(strip.Color(0, 200, 0), 25); // Green
colorWipe(strip.Color(0, 0, 200), 25); // Blue
// Send a theater pixel chase in...
theaterChase(strip.Color(70, 70, 70), 250); // White
theaterChase(strip.Color(70, 0, 0), 250); // Red
theaterChase(strip.Color(0, 0, 70), 250); // Blue
theaterChase(strip.Color(0, 70, 70), 250); // Blue
theaterChase(strip.Color(70, 0, 70), 250); // Blue
theaterChase(strip.Color(0, 70, 0), 250); // Blue
}
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) {  //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c);    //turn every third pixel on
}
strip.show();
delay(wait);
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0);        //turn every third pixel off
}
}
}
}

This is based on the srandtest included with the Adafruit NeoPixel Library (which is required for this to work). This assumes that your DATA pin is 6.

Power Consumption Estimates

Initially we were working on data from our supplier that each of the LEDs in the pixel strings used about 18 mA of power on average. In our default 2 x 8 stick layout, this would mean since we have 16 pixels, that would mean an average consumption of 288mA per Accessible Pixel Stick. However, these estimates aren’t quite right for maximum power consumption.

18mA per LED: 16 x 18mA = 288mA per Accessible Pixel Stick
Approximate power dissipation ( 5v x 0.66A ): 1.44 watts

After testing both an NeoPixel clone from the UK mixed with a generic WS2812-8 from China, the maximum current draw that we have measured is approximately 660mA. This is with every pixel set to maximum (255 on each colour) so it’s a very bright almost white.

Working backwards this means that the maximum current draw would be 660mA

660mA / 16 = 41.25mA per LED
Approximate power dissipation ( 5v x 0.66A ): 3.3 watts

Knowing what we know about LEDs, however, each LED would theoretically draw a maximum of about 20mA, so each pixel at full intensity would run at 60mA giving us a total per Accessible Pixel Stick of 960mA

20mA per LED: 16 x 60mA = 960mA per Accessible Pixel Stick
Approximate Power dissipation ( 5v x 0.96A ): 4.8 watts

Of course, we won’t be running these LEDs at maximum, for both thermal and for the life of the LED strips. We’d probably recommend running them at 60% of maximum as the highest setting.

960mA * 60 / 100 = 576mA per Accessible Pixel Stick
Approximate Power dissipation ( 5v x 0.576A ): 2.88 watts

2.88 watts over 16 LEDs sounds like a good upper limit for the LEDs to us.

Donations at GoFundMe

Lighting projects and the tools to create them are not easy to access. We want to create accessible lighting modules for use on accessible vehicles (such as wheelchairs), bags and clothing.

Often lighting projects, especially for wheelchairs, are very clinical or medical – We wish to bring colourful and unique designs that are tailored around user’s specific needs.

We also wish to release the code as open source to teach other people and therefore giving them the knowledge. With relative ease our designs can be used and modified at little to no cost to the end user.

.

Skip to content