Carol Chesney
Published

Hand Signal Vest

Turn on your blinker with a hand signal. Turn it off with the flick of the wrist.

IntermediateWork in progress2 hours739
Hand Signal Vest

Things used in this project

Hardware components

LightBlue Bean
Punch Through LightBlue Bean
×1
Flora RGB Neopixel LEDs- Pack of 4
Adafruit Flora RGB Neopixel LEDs- Pack of 4
×2
Capacitor 1000 µF
Capacitor 1000 µF
Recommended for Neopixel best practices. I used in conjunction with 3x AAA battery pack.
×1
Resistor 221 ohm
Resistor 221 ohm
Something in the 100-300 ohm range is recommended for Neopixel best practices. You might not find it necessary.
×1

Story

Read more

Schematics

Turn signal vest

Connection Guide. Adafruit's "best practices" recommend 100-300 ohm between signal and first NeoPixel and at least a 1000 µF capacitor across the power input
Untitled%20drawing

Code

Turn signal vest

Arduino
Bean's accelerometer detects hand signals and displays left or right turn signals on a vest
/*
  Turn signal vest:
  uses Lightblue Bean & Adafruit's Neopixel

  This sketch reads the acceleration from the Bean's accelerometer
  to drive 3 modes

    warn:     flashes Bean orange & vest orange pattern
    left:     flashes Bean green & vest green Left arrow
    right:    flashes Bean blue & vest green right arrow

*/

#include <Adafruit_NeoPixel.h>
#define NEO_PIN 4
#define NEOS 8
#define WRIST_OFF -100
#define WRIST_RIGHT 222
#define WRIST_LEFT_X 180
#define WRIST_LEFT_Y 30
#define WRIST_LEFT_Z -30
#define FLICK -100

// prototypes
void blink_warn( void ) ;
void blink_right(AccelerationReading accel) ;
void blink_left(AccelerationReading accel) ;

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NEOS, NEO_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  Bean.setAccelerationRange(2);    // ensure range of +- 2g
  pixels.begin(); // Initialize NeoPixel library
}

void loop() {
  int i;
  // set mode based on accell, and flash accordinglingly

  AccelerationReading accel = Bean.getAcceleration();
  if ( accel.yAxis > WRIST_RIGHT )        //check for right turn
    blink_right (accel);
  else {  // check for left tutrn
    if ( (accel.xAxis > WRIST_LEFT_X) && (accel.yAxis > WRIST_LEFT_Y) && (accel.zAxis < WRIST_LEFT_Z) )
      blink_left (accel);
    else {
      blink_warn();           //blink_orange
    }
  }
}

void blink_right(AccelerationReading accel) {
  int i;
  do {
    Bean.setLed(0, 0, 110);
    for (i = 3; i < 8; i++)
      pixels.setPixelColor(i, pixels.Color(0, 110, 0));
    pixels.show();
    Bean.sleep(100);
    Bean.setLed(0, 0, 0);
    for (i = 3; i < 8; i++)
      pixels.setPixelColor(i, pixels.Color(0, 0, 0));
    pixels.show();
    for (i = 0; i < 5; i++) { // check in 100 ms intervals so you don't miss wrist flick
      Bean.sleep(100);
      accel = Bean.getAcceleration();
      if (accel.zAxis < FLICK) {    // check for wrist flick
        Bean.sleep(400);          // let wrist flick reset w/o triggering a left turn
        return;
      }
    }
  } while (1);
}

void blink_left(AccelerationReading accel) {
  int i;
  do {
    Bean.setLed(0, 110, 0);
    for (i = 0; i < 4; i++)
      pixels.setPixelColor(i, pixels.Color(0, 110, 0));
    pixels.setPixelColor(7, pixels.Color(0, 110, 0));
    pixels.show();
    Bean.sleep(100);
    Bean.setLed(0, 0, 0);
    for (i = 0; i < 4; i++)
      pixels.setPixelColor(i, pixels.Color(0, 0, 0));
    pixels.setPixelColor(7, pixels.Color(0, 0, 0));
    pixels.show();
    for (i = 0; i < 5; i++) { // check in 100 ms intervals so you don't miss wrist flick
      Bean.sleep(100);
      accel = Bean.getAcceleration();
      if (accel.zAxis < FLICK) {    // check for wrist flick
        Bean.sleep(400);          // let wrist flick reset w/o triggering a left turn
        return;
      }
    }
  } while (1);
}

void blink_warn( void ) {
  int i;
  Bean.setLed(70, 50, 0);
  for (i = 0; i < 8; i += 2)
    pixels.setPixelColor(i, pixels.Color(80, 50, 0));
  pixels.show();
  Bean.sleep(100);
  Bean.setLed(0, 0, 0);
  for (i = 0; i < 8; i += 2)
    pixels.setPixelColor(i, pixels.Color(0, 0, 0));
  pixels.show();
  Bean.sleep(400);
  for (i = 1; i < 8; i += 2)
    pixels.setPixelColor(i, pixels.Color(80, 50, 0));
  pixels.show();
  Bean.sleep(100);
  for (i = 1; i < 8; i += 2)
    pixels.setPixelColor(i, pixels.Color(0, 0, 0));
  pixels.show();
  Bean.sleep(400);
}

Credits

Carol Chesney

Carol Chesney

4 projects • 6 followers
Mechanical engineer and teacher

Comments

Add projectSign up / Login