Firewalker sneaks

Wearable electronics: boards, conductive materials, and projects from Adafruit!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
lejaybo
 
Posts: 30
Joined: Fri Aug 30, 2013 10:08 am

Firewalker sneaks

Post by lejaybo »

Hi,

so i've put together some firewalker sneaks and have been playing about with some scanner patterns

its scans from each end of the neopixel strip with random colours

http://youtu.be/aEvJsrg7IBg

Code: Select all

#include <Adafruit_NeoPixel.h>

#define N_LEDS 42 
#define PIN    12
 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

[color=#CC6600]int[/color] RED;
[color=#CC6600]int[/color] GRE; 
[color=#CC6600]int[/color] BLU;
 
[color=#CC6600]void[/color] [color=#CC6600][b]setup[/b][/color]() {
  strip.[color=#CC6600]begin[/color]();
}

[color=#CC6600]int[/color] pos = 0, dir = 1; [color=#7E7E7E]// Position, direction of "eye"[/color]
[color=#CC6600]int[/color] pos2 = 41, dir2 = 1;

[color=#CC6600]void[/color] [color=#CC6600][b]loop[/b][/color]() {
  
  RED = [color=#CC6600]random[/color](255);
  GRE = [color=#CC6600]random[/color](255);
  BLU = [color=#CC6600]random[/color](255);
  
  [color=#CC6600]int[/color] j;
  [color=#7E7E7E]// Draw 5 pixels centered on pos.  setPixelColor() will clip any[/color]
  [color=#7E7E7E]// pixels off the ends of the strip, we don't need to watch for that.[/color]
  strip.setPixelColor(pos - 2, RED, GRE, BLU); [color=#7E7E7E]// Dark red[/color]
  strip.setPixelColor(pos - 1, RED, GRE, BLU); [color=#7E7E7E]// Medium red[/color]
  strip.setPixelColor(pos    , RED, GRE, BLU); [color=#7E7E7E]// Center pixel is brightest[/color]
  strip.setPixelColor(pos + 1, RED, GRE, BLU); [color=#7E7E7E]// Medium red[/color]
  strip.setPixelColor(pos + 2, RED, GRE, BLU); [color=#7E7E7E]// Dark red[/color]
  
  strip.setPixelColor(pos2 + 2, RED, GRE, BLU); [color=#7E7E7E]// Dark red[/color]
  strip.setPixelColor(pos2 + 1, RED, GRE, BLU); [color=#7E7E7E]// Medium red[/color]
  strip.setPixelColor(pos2    , RED, GRE, BLU); [color=#7E7E7E]// Center pixel is brightest[/color]
  strip.setPixelColor(pos2 - 1, RED, GRE, BLU); [color=#7E7E7E]// Medium red[/color]
  strip.setPixelColor(pos2 - 2, RED, GRE, BLU); [color=#7E7E7E]// Dark red[/color]
    
  strip.show();
  [color=#CC6600]delay[/color](60);
 
  [color=#7E7E7E]// Rather than being sneaky and erasing just the tail pixel,[/color]
  [color=#7E7E7E]// it's easier to erase it all and draw a new one next time.[/color]
  [color=#CC6600]for[/color](j=-2; j<= 2; j++) strip.setPixelColor(pos+j, 0);
  [color=#CC6600]for[/color](j=-2; j<= 2; j++) strip.setPixelColor(pos2+j, 0);
 
  [color=#7E7E7E]// Bounce off ends of strip[/color]
  pos += dir;
  [color=#CC6600]if[/color](pos < 0) {
    pos = 1;
    dir = -dir;
  } [color=#CC6600]else[/color] [color=#CC6600]if[/color](pos >= strip.numPixels()) {
    pos = strip.numPixels() - 2;
    dir = -dir;
  }
  pos2 += dir2;
  [color=#CC6600]if[/color](pos2 < 0) {
    pos2 = 1;
    dir2 = -dir2;
  } [color=#CC6600]else[/color] [color=#CC6600]if[/color](pos2 >= strip.numPixels()) {
    pos2 = strip.numPixels() - 2;
    dir2 = -dir2;
  }
}



User avatar
adafruit_support_bill
 
Posts: 89205
Joined: Sat Feb 07, 2009 10:11 am

Re: Firewalker sneaks

Post by adafruit_support_bill »

Cool! Thanks for posting. :D

Locked
Please be positive and constructive with your questions and comments.

Return to “Wearables”