Hi.. can you please let me know the flora code to blink led pixel and fade code also ?
thanks
Flora Coding
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Flora Coding
Can you be more specific? How many pixels? Fade from what color to what color?
Have you tried the example code from the guide? http://learn.adafruit.com/flora-rgb-sma ... -test-code
Have you tried the example code from the guide? http://learn.adafruit.com/flora-rgb-sma ... -test-code
- skelhoney
- Posts: 48
- Joined: Fri Jun 14, 2013 3:04 pm
Re: Flora Coding
hi... Yes i tried that example code but i want to turn it off and on ?
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Flora Coding
You haven't given us any details about how many pixels you have or how they are wired. But this should blink one pixel connected to pin 6:
Code: Select all
#define LEDPIN 6;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, LEDPIN, NEO_GRB + NEO_KHZ800);
void setup()
{
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop()
{
strip.setPixelColor(0, strip.Color(255,255,255)); // white
strip.show();
delay(1000);
strip.setPixelColor(0, strip.Color(0,0,0)); // black
strip.show();
delay(1000);
}
- skelhoney
- Posts: 48
- Joined: Fri Jun 14, 2013 3:04 pm
Re: Flora Coding
hi....sorry i am new in it i am not able to upload this code please see that attached pic with uploading error and i am using 4 pixels please send correct code. i want all the effects in 1 one code like blink then fade and then colors change. send me any simple code that i can change according to me. i am using this below code for led strip ws2801 send me something like this
Code: Select all
/*
Nathan Seidle
SparkFun Electronics 2011
This code is public domain but you buy me a beer if you use this and we meet someday (Beerware license).
Controlling an LED strip with individually controllable RGB LEDs. This stuff is awesome.
The SparkFun (individually controllable) RGB strip contains a bunch of WS2801 ICs. These
are controlled over a simple data and clock setup. The WS2801 is really cool! Each IC has its
own internal clock so that it can do all the PWM for that specific LED for you. Each IC
requires 24 bits of 'greyscale' data. This means you can have 256 levels of red, 256 of blue,
and 256 levels of green for each RGB LED. REALLY granular.
To control the strip, you clock in data continually. Each IC automatically passes the data onto
the next IC. Once you pause for more than 500us, each IC 'posts' or begins to output the color data
you just clocked in. So, clock in (24bits * 32LEDs = ) 768 bits, then pause for 500us. Then
repeat if you wish to display something new.
This example code will display bright red, green, and blue, then 'trickle' random colors down
the LED strip.
You will need to connect 5V/Gnd from the Arduino (USB power seems to be sufficient).
For the data pins, please pay attention to the arrow printed on the strip. You will need to connect to
the end that is the begining of the arrows (data connection)--->
If you have a 4-pin connection:
Blue = 5V
Red = SDI
Green = CKI
Black = GND
If you have a split 5-pin connection:
2-pin Red+Black = 5V/GND
Green = CKI
Red = SDI
*/
int x;
int SDI = 2; //Red wire (not the red 5V wire!)
int CKI = 3; //Green wire
int ledPin = 13; //On board LED
#define STRIP_LENGTH 32 //32 LEDs on this strip
long strip_colors[STRIP_LENGTH];
void setup() {
pinMode(SDI, OUTPUT);
pinMode(CKI, OUTPUT);
pinMode(ledPin, OUTPUT);
//Clear out the array
for(int x = 0 ; x < STRIP_LENGTH ; x++)
strip_colors[x] = 0;
randomSeed(analogRead(0));
//Serial.begin(9600);
//Serial.println("Hello!");
}
void loop() {
{
strip_colors[0] = 0xFF0000; //Bright Red
strip_colors[1] = 0xFF0000; //Bright Green
strip_colors[2] = 0xFF0000; //Bright Blue
strip_colors[3] = 0xFF0000; //Faint red
strip_colors[4] = 0xFF0000; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(1);
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(1);
delay(8000);
delay(9785);
// All Colors Change
//Bright Red
//Pre-fill the color array with known values
{
{for (x = 0; x < 4; x++) {
//Bright Green
//Pre-fill the color array with known values
strip_colors[0] = 0x555555; //Bright Red
strip_colors[1] = 0x555555; //Bright Green
strip_colors[2] = 0x555555; //Bright Blue
strip_colors[3] = 0x555555; //Faint red
strip_colors[4] = 0x555555; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(60);
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(60);
}
//Bright Blue
//Pre-fill the color array with known values
strip_colors[0] = 0x00008B; //Bright Red
strip_colors[1] = 0x00008B; //Bright Green
strip_colors[2] = 0x00008B; //Bright Blue
strip_colors[3] = 0x00008B; //Faint red
strip_colors[4] = 0x00008B; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(2000);
//Bright Green
//Pre-fill the color array with known values
strip_colors[0] = 0x00FF00; //Bright Red
strip_colors[1] = 0x00FF00; //Bright Green
strip_colors[2] = 0x00FF00; //Bright Blue
strip_colors[3] = 0x00FF00; //Faint red
strip_colors[4] = 0x00FF00; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(2000);
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(2553);
}
{
{for (x = 0; x < 4; x++) {
//Bright Green
//Pre-fill the color array with known values
strip_colors[0] = 0x555555; //Bright Red
strip_colors[1] = 0x555555; //Bright Green
strip_colors[2] = 0x555555; //Bright Blue
strip_colors[3] = 0x555555; //Faint red
strip_colors[4] = 0x555555; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(60);
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(60);
}
//Bright Blue
//Pre-fill the color array with known values
strip_colors[0] = 0x00008B; //Bright Red
strip_colors[1] = 0x00008B; //Bright Green
strip_colors[2] = 0x00008B; //Bright Blue
strip_colors[3] = 0x00008B; //Faint red
strip_colors[4] = 0x00008B; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(1000);
{
{for (x = 0; x < 10; x++) {
//Bright Green
//Pre-fill the color array with known values
strip_colors[0] = 0xFF0000; //Bright Red
strip_colors[1] = 0xFF0000; //Bright Green
strip_colors[2] = 0xFF0000; //Bright Blue
strip_colors[3] = 0xFF0000; //Faint red
strip_colors[4] = 0xFF0000; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(20);
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(20);
}
delay(2500);
{
{for (x = 0; x < 4; x++) {
//Bright Green
//Pre-fill the color array with known values
strip_colors[0] = 0x555555; //Bright Red
strip_colors[1] = 0x555555; //Bright Green
strip_colors[2] = 0x555555; //Bright Blue
strip_colors[3] = 0x555555; //Faint red
strip_colors[4] = 0x555555; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(60);
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(60);
}
//Bright Blue
//Pre-fill the color array with known values
strip_colors[0] = 0x00008B; //Bright Red
strip_colors[1] = 0x00008B; //Bright Green
strip_colors[2] = 0x00008B; //Bright Blue
strip_colors[3] = 0x00008B; //Faint red
strip_colors[4] = 0x00008B; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(3000);
{
{for (x = 0; x < 10; x++) {
//Bright Green
//Pre-fill the color array with known values
strip_colors[0] = 0xFF0000; //Bright Red
strip_colors[1] = 0xFF0000; //Bright Green
strip_colors[2] = 0xFF0000; //Bright Blue
strip_colors[3] = 0xFF0000; //Faint red
strip_colors[4] = 0xFF0000; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(20);
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(20);
}
delay(2500);
//Bright Green
//Pre-fill the color array with known values
strip_colors[0] = 0xFF0000; //Bright Red
strip_colors[1] = 0xFF0000; //Bright Green
strip_colors[2] = 0xFF0000; //Bright Blue
strip_colors[3] = 0xFF0000; //Faint red
strip_colors[4] = 0xFF0000; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(14351);
{
{for (x = 0; x < 20; x++) {
//Bright Green
//Pre-fill the color array with known values
strip_colors[0] = 0xFF0000; //Bright Red
strip_colors[1] = 0xFF0000; //Bright Green
strip_colors[2] = 0xFF0000; //Bright Blue
strip_colors[3] = 0xFF0000; //Faint red
strip_colors[4] = 0xFF0000; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(20);
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(20);
}
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(40000);
{
{for (x = 0; x < 12; x++) {
//Bright Green
//Pre-fill the color array with known values
strip_colors[0] = 0xFF0000; //Bright Red
strip_colors[1] = 0xFF0000; //Bright Green
strip_colors[2] = 0xFF0000; //Bright Blue
strip_colors[3] = 0xFF0000; //Faint red
strip_colors[4] = 0xFF0000; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(100);
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
post_frame(); //Push the current color frame to the strip
delay(100);
}
strip_colors[0] = LOW; //Bright Red
strip_colors[1] = LOW; //Bright Green
strip_colors[2] = LOW; //Bright Blue
strip_colors[3] = LOW; //Faint red
strip_colors[4] = LOW; //Bright Red
delay(200000000);
}}}}}}}}}}}}}
}}
//Throws random colors down the strip array
void addRandom(void) {
int x;
//First, shuffle all the current colors down one spot on the strip
for(x = (STRIP_LENGTH - 1) ; x > 0 ; x--)
strip_colors[x] = strip_colors[x - 1];
//Now form a new RGB color
long new_color = 0;
for(x = 0 ; x < 3 ; x++){
new_color <<= 8;
new_color |= random(0xFF); //Give me a number from 0 to 0xFF
//new_color &= 0x555555; //Force the random number to just the upper brightness levels. It sort of works.
}
strip_colors[0] = new_color; //Add the new random color to the strip
}
//Takes the current strip color array and pushes it out
void post_frame (void) {
//Each LED requires 24 bits of data
//MSB: R7, R6, R5..., G7, G6..., B7, B6... B0
//Once the 24 bits have been delivered, the IC immediately relays these bits to its neighbor
//Pulling the clock low for 500us or more causes the IC to post the data.
for(int LED_number = 0 ; LED_number < STRIP_LENGTH ; LED_number++) {
long this_led_color = strip_colors[LED_number]; //24 bits of color data
for(byte color_bit = 23 ; color_bit != 255 ; color_bit--) {
//Feed color bit 23 first (red data MSB)
digitalWrite(CKI, LOW); //Only change data when clock is low
long mask = 1L << color_bit;
//The 1'L' forces the 1 to start as a 32 bit number, otherwise it defaults to 16-bit.
if(this_led_color & mask)
digitalWrite(SDI, HIGH);
else
digitalWrite(SDI, LOW);
digitalWrite(CKI, HIGH); //Data is latched when clock goes high
}
}
//Pull clock low to put strip into reset/post mode
digitalWrite(CKI, LOW);
delayMicroseconds(500); //Wait for 500us to go into reset
}
- Attachments
-
- uploading error
- flora.jpg (144.84 KiB) Viewed 14084 times
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Flora Coding
You have code for two completely different types of pixels there. What pixels are you using? Please post a link.
We can't help you unless you tell us exactly what pixels you are trying to control.
We can't help you unless you tell us exactly what pixels you are trying to control.
- skelhoney
- Posts: 48
- Joined: Fri Jun 14, 2013 3:04 pm
Re: Flora Coding
Hi... Using this pixel in the http://www.adafruit.com/products/1260
the below code you send me that is not working as i send u the error pitcher
please send the code for blink, fade and color change
below code is not working for me
the below code you send me that is not working as i send u the error pitcher
please send the code for blink, fade and color change
below code is not working for me
Code: Select all
#define LEDPIN 6;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, LEDPIN, NEO_GRB + NEO_KHZ800);
void setup()
{
strip.begin();
strip.show(); // Initialize all pixels to 'off'
}
void loop()
{
strip.setPixelColor(0, strip.Color(255,255,255)); // white
strip.show();
delay(1000);
strip.setPixelColor(0, strip.Color(0,0,0)); // black
strip.show();
delay(1000);
}
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Flora Coding
Post an example sketch that works with your pixels.
- skelhoney
- Posts: 48
- Joined: Fri Jun 14, 2013 3:04 pm
Re: Flora Coding
Hi i am using below given code but that code not so simple i want simple that i can change according to me
Please help me in that
Please help me in that
Code: Select all
#include "Adafruit_FloraPixel.h"
/*****************************************************************************
Example sketch for driving Adafruit Flora pixels
Connect the pixel(s) to Digital 6 (low right hand)
*****************************************************************************/
// Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a row
Adafruit_FloraPixel strip = Adafruit_FloraPixel(8);
void setup() {
strip.begin();
// Update the strip, to start they are all 'off'
strip.show();
}
void loop() {
// Some example procedures showing how to display to the pixels
colorWipe(Color(255, 0, 0), 50);
colorWipe(Color(255, 255, 0), 50);
colorWipe(Color(0, 255, 0), 50);
colorWipe(Color(0, 255, 255), 50);
colorWipe(Color(0, 0, 255), 50);
colorWipe(Color(255, 0, 255), 50);
colorWipe(Color(255, 255, 255), 50);
delay(1000);
rainbowCycle(1);
}
void rainbow(uint8_t wait) {
int i, j;
for (j=0; j < 256; j++) { // 3 cycles of all 256 colors in the wheel
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel( (i + j) % 255));
}
strip.show(); // write all the pixels out
delay(wait);
}
}
// Slightly different, this one makes the rainbow wheel equally distributed
// along the chain
void rainbowCycle(uint8_t wait) {
int i, j;
for (j=0; j < 256 * 5; j++) { // 5 cycles of all 25 colors in the wheel
for (i=0; i < strip.numPixels(); i++) {
// tricky math! we use each pixel as a fraction of the full 96-color wheel
// (thats the i / strip.numPixels() part)
// Then add in j which makes the colors go around per pixel
// the % 96 is to make the wheel cycle around
strip.setPixelColor(i, Wheel( ((i * 256 / strip.numPixels()) + j) % 256) );
}
strip.show(); // write all the pixels out
delay(wait);
}
}
// fill the dots one after the other with said color
// good for testing purposes
void colorWipe(RGBPixel c, uint8_t wait) {
int i;
for (i=0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
/* Helper functions */
// Create a 24 bit color value from R,G,B
RGBPixel Color(byte r, byte g, byte b)
{
RGBPixel p;
p.red = r;
p.green = g;
p.blue = b;
return p;
}
//Input a value 0 to 255 to get a color value.
//The colours are a transition r - g -b - back to r
RGBPixel Wheel(byte WheelPos)
{
if (WheelPos < 85) {
return Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Flora Coding
Code: Select all
#include "Adafruit_FloraPixel.h"
/*****************************************************************************
Example sketch for driving Adafruit Flora pixels
Connect the pixel(s) to Digital 6 (low right hand)
*****************************************************************************/
// Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a row
Adafruit_FloraPixel strip = Adafruit_FloraPixel(8);
void setup() {
strip.begin();
// Update the strip, to start they are all 'off'
strip.show();
}
void loop() {
// Some example procedures showing how to display to the pixels
Blink(5, 500, Color(255, 255, 255), Color(0,0,0)); // blink white
Blink(5, 500, Color(255, 0, 0), Color(0,0,0)); // blink red
Blink(5, 500, Color(0, 255, 0), Color(0,0,0)); // blink green
Blink(5, 500, Color(0, 0, 255), Color(0,0,0)); // blink blue
Fade(10, Color(255, 255, 255)); // fade white
Fade(10, Color(255, 0, 0)); // fade red
Fade(10, Color(0, 255, 0)); // fade green
Fade(10, Color(0, 0, 255)); // fade blue
}
// alternate between on and off color with delay
void Blink(int count, int ms, RGBPixel on, RGBPixel off)
{
for (int i = 0; i < count; i++)
{
for (int j = 0; j < strip.numPixels(); j++)
{
strip.setPixelColor(j, on);
}
delay(ms);
for (int j = 0; j < strip.numPixels(); j++)
{
strip.setPixelColor(j, off);
}
delay(ms);
}
}
// fade from start color to black
void Fade(int ms, RGBPixel start)
{
for (int i = 0; i < 255; i++)
{
RGBPixel color = Color(start.red / i, start.green / i, start.blue / i);
for (int j = 0; j < strip.numPixels(); j++)
{
strip.setPixelColor(j, color);
}
delay(ms);
}
}
/* Helper functions */
// Create a 24 bit color value from R,G,B
RGBPixel Color(byte r, byte g, byte b)
{
RGBPixel p;
p.red = r;
p.green = g;
p.blue = b;
return p;
}
- skelhoney
- Posts: 48
- Joined: Fri Jun 14, 2013 3:04 pm
Re: Flora Coding
Thanks for the code but when i upload this code nothing is happening. have you try this code ?
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Flora Coding
Sorry, forgot the calls to "strip.show()"
Code: Select all
#include "Adafruit_FloraPixel.h"
/*****************************************************************************
Example sketch for driving Adafruit Flora pixels
Connect the pixel(s) to Digital 6 (low right hand)
*****************************************************************************/
// Set the first variable to the NUMBER of pixels. 25 = 25 pixels in a row
Adafruit_FloraPixel strip = Adafruit_FloraPixel(8);
void setup() {
strip.begin();
// Update the strip, to start they are all 'off'
strip.show();
}
void loop() {
// Some example procedures showing how to display to the pixels
Blink(5, 500, Color(255, 255, 255), Color(0,0,0)); // blink white
Blink(5, 500, Color(255, 0, 0), Color(0,0,0)); // blink red
Blink(5, 500, Color(0, 255, 0), Color(0,0,0)); // blink green
Blink(5, 500, Color(0, 0, 255), Color(0,0,0)); // blink blue
Fade(10, Color(255, 255, 255)); // fade white
Fade(10, Color(255, 0, 0)); // fade red
Fade(10, Color(0, 255, 0)); // fade green
Fade(10, Color(0, 0, 255)); // fade blue
}
// alternate between on and off color with delay
void Blink(int count, int ms, RGBPixel on, RGBPixel off)
{
for (int i = 0; i < count; i++)
{
for (int j = 0; j < strip.numPixels(); j++)
{
strip.setPixelColor(j, on);
}
strip.show();
delay(ms);
for (int j = 0; j < strip.numPixels(); j++)
{
strip.setPixelColor(j, off);
}
strip.show();
delay(ms);
}
}
// fade from start color to black
void Fade(int ms, RGBPixel start)
{
for (int i = 0; i < 255; i++)
{
RGBPixel color = Color(start.red / i, start.green / i, start.blue / i);
for (int j = 0; j < strip.numPixels(); j++)
{
strip.setPixelColor(j, color);
}
strip.show();
delay(ms);
}
}
/* Helper functions */
// Create a 24 bit color value from R,G,B
RGBPixel Color(byte r, byte g, byte b)
{
RGBPixel p;
p.red = r;
p.green = g;
p.blue = b;
return p;
}
- skelhoney
- Posts: 48
- Joined: Fri Jun 14, 2013 3:04 pm
Re: Flora Coding
Hi... Thanks for the code this is working but can you please let me know how can i control every single pixel. i mean to say is there is 4 pixel and i want to turn on only 1st and 4th then how can i do that can you put any pixel number in this code. this is only doing fade out i want both fade out and fade in.
thanks
thanks
- adafruit_support_bill
- Posts: 88090
- Joined: Sat Feb 07, 2009 10:11 am
Re: Flora Coding
The pixel number is the first parameter to setPixelColor. You can specify any pixel number you like.can you please let me know how can i control every single pixel. i mean to say is there is 4 pixel and i want to turn on only 1st and 4th
Just edit the 'for' loop to count down instead of up. http://arduino.cc/en/Reference/forthis is only doing fade out i want both fade out and fade in.
Please be positive and constructive with your questions and comments.