coding pixel strip

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
matt_aus
 
Posts: 9
Joined: Sun Sep 29, 2013 5:06 am

coding pixel strip

Post by matt_aus »

#include <Adafruit_NeoPixel.h>

#define PIN 6
Hi
I am really enjoying the neo pixel strip!
I am trying to get as much info about coding the strip to create lots of effects

with the strandtest i love the single chase of colours.
but when i just want to loop this effect i cannot get it to work? (below code)

also how do i add more various colours e.g: light purple?

Thanks

Is there a place where i can get sample codes? or can you advise how i can program

Code: Select all

// Parameter 1 = number of pixels in strip
// Parameter 2 = 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)

Adafruit_NeoPixel strip = Adafruit_NeoPixel(27, PIN, NEO_GRB + NEO_KHZ800);

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(255, 0, 0), 50); // Red
  colorWipe(strip.Color(0, 255, 0), 50); // Green
  colorWipe(strip.Color(0, 0, 255), 50); // Blue
  rainbow(20);
  rainbowCycle(20);
}
Last edited by adafruit_support_bill on Mon Oct 21, 2013 6:23 am, edited 1 time in total.
Reason: Please use the 'code' button when submitting code - click 'code' and paste your code between the tags.

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

Re: coding pixel strip

Post by adafruit_support_bill »

with the strandtest i love the single chase of colours.
but when i just want to loop this effect i cannot get it to work? (below code)
Not sure which effect it is that you like, but try commenting out one line at a time in the 'loop()' function of strandtest. You should be able to eliminate all except for the one you want to keep.


There is a library reference for the neopixel library here: http://learn.adafruit.com/adafruit-neop ... no-library
And there are lots of projects with example code to follow in the learning system: http://learn.adafruit.com/search?q=neopixel

matt_aus
 
Posts: 9
Joined: Sun Sep 29, 2013 5:06 am

Re: coding pixel strip

Post by matt_aus »

Hi,
Thanks for the links - had a look at all of them.
this is the code i'm working with:

Code: Select all

#include <Adafruit_NeoPixel.h>

#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

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(255, 0, 0), 50); // Red
  colorWipe(strip.Color(0, 255, 0), 50); // Green
  colorWipe(strip.Color(0, 0, 255), 50); // 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);
  }
}

I understand the colour wipe section and the vales make the RGB change.
but its this bit that i am having trouble understanding?

// 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);
  }
}
How for example would i get the strip to run a few colour wipes and then move back in the opposite direction
and then move to a different pattern?
I can't work out how to loop for a exact amount of time?

Thanks
Last edited by adafruit_support_bill on Mon Oct 28, 2013 6:16 am, edited 1 time in total.
Reason: Please use the 'code' button when submitting code - click 'code' and paste your code between the tags.

EternalCore
 
Posts: 239
Joined: Tue Jul 30, 2013 3:57 pm

Re: coding pixel strip

Post by EternalCore »

Hi, Here use my example to help understanding lighting directions [Example]NeoPixel Strip Scrolling Cylon Eye!: http://goo.gl/4RzWQQ

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

Return to “Arduino”