PololuLedStrip-add Bluetooth
hey guys, i've been trying add bluetooth connectivity example sketch have been unsuccessful. have hc-06 bt device ready connect nano. i'm using ws2811 leds , wish turn them on , off on bt.
if 1 can appreciate it.
thanks
here code i'm running:
/* ledstriprainbow: example arduino sketch shows
* how make moving rainbow pattern on an
* addressable rgb led strip pololu.
*
* use this, need plug addressable rgb led
* strip pololu pin 12. after uploading sketch,
* should see moving rainbow.
*/
#include <pololuledstrip.h>
// create ledstrip object , specify pin use.
pololuledstrip<6> ledstrip;
// create buffer holding colors (3 bytes per color).
#define led_count 30
rgb_color colors[led_count];
void setup()
{
}
// converts color hsv rgb.
// h hue, number between 0 , 360.
// s saturation, number between 0 , 255.
// v value, number between 0 , 255.
rgb_color hsvtorgb(uint16_t h, uint8_t s, uint8_t v)
{
uint8_t f = (h % 60) * 255 / 60;
uint8_t p = (255 - s) * (uint16_t)v / 255;
uint8_t q = (255 - f * (uint16_t)s / 255) * (uint16_t)v / 255;
uint8_t t = (255 - (255 - f) * (uint16_t)s / 255) * (uint16_t)v / 255;
uint8_t r = 0, g = 0, b = 0;
switch((h / 60) % 6){
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
case 5: r = v; g = p; b = q; break;
}
return rgb_color(r, g, b);
}
void loop()
{
// update colors.
uint16_t time = millis() >> 2;
for(uint16_t = 0; < led_count; i++)
{
byte x = (time >> 2) - (i << 3);
colors = hsvtorgb((uint32_t)x * 359 / 256, 255, 255);
}
// write colors led strip.
ledstrip.write(colors, led_count);
delay(70);
}
if 1 can appreciate it.
thanks
here code i'm running:
/* ledstriprainbow: example arduino sketch shows
* how make moving rainbow pattern on an
* addressable rgb led strip pololu.
*
* use this, need plug addressable rgb led
* strip pololu pin 12. after uploading sketch,
* should see moving rainbow.
*/
#include <pololuledstrip.h>
// create ledstrip object , specify pin use.
pololuledstrip<6> ledstrip;
// create buffer holding colors (3 bytes per color).
#define led_count 30
rgb_color colors[led_count];
void setup()
{
}
// converts color hsv rgb.
// h hue, number between 0 , 360.
// s saturation, number between 0 , 255.
// v value, number between 0 , 255.
rgb_color hsvtorgb(uint16_t h, uint8_t s, uint8_t v)
{
uint8_t f = (h % 60) * 255 / 60;
uint8_t p = (255 - s) * (uint16_t)v / 255;
uint8_t q = (255 - f * (uint16_t)s / 255) * (uint16_t)v / 255;
uint8_t t = (255 - (255 - f) * (uint16_t)s / 255) * (uint16_t)v / 255;
uint8_t r = 0, g = 0, b = 0;
switch((h / 60) % 6){
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
case 5: r = v; g = p; b = q; break;
}
return rgb_color(r, g, b);
}
void loop()
{
// update colors.
uint16_t time = millis() >> 2;
for(uint16_t = 0; < led_count; i++)
{
byte x = (time >> 2) - (i << 3);
colors = hsvtorgb((uint32_t)x * 359 / 256, 255, 255);
}
// write colors led strip.
ledstrip.write(colors, led_count);
delay(70);
}
that code not expect user input. have define input want provide.
that independent getting bluetooth hardware connected , working correctly. not try working in sketch.
that independent getting bluetooth hardware connected , working correctly. not try working in sketch.
Arduino Forum > Using Arduino > Programming Questions > PololuLedStrip-add Bluetooth
arduino
Comments
Post a Comment