Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

Help trinket 5v neopixel
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Help trinket 5v neopixel

by JorenSmet on Mon May 11, 2020 6:56 pm

Hello,

I'm trying to get my trinket to just show a purple color across all the leds of my neopixel stick (8leds) but i can't seem to figure it out.

This is what i have so far:


Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN    1
 
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 8
 
// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 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)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
void setup() {
   // These lines are specifically to support the Adafruit Trinket 5V 16 MHz.
  // Any other board, you can remove this part (but no harm leaving it):
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000)
  clock_prescale_set(clock_div_1);
#endif
  // END of Trinket-specific code.
 
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
 
  strip.setPixelColor(0, 0, 100, 100, 20);
  strip.setPixelColor(7, 0, 100, 100, 20);
}

void loop() {
  // put your main code here, to run repeatedly:
  strip.setPixelColor(0, 0, 100, 100, 20);
  strip.setPixelColor(7, 0, 100, 100, 20);
}


(trinket: https://www.adafruit.com/product/1501)
thanks in advance!

JorenSmet
 
Posts: 2
Joined: Tue May 31, 2016 4:54 pm

Re: Help trinket 5v neopixel

by adafruit_support_carter on Mon May 11, 2020 7:35 pm

Are you able to upload and run the basic blink example OK?
https://learn.adafruit.com/introducing- ... #blink-6-5

That version of the Trinket is deprecated. So just want to make sure you are actually able to program it. Here's the newer version of the Trinket:
https://www.adafruit.com/product/3500

To set all pixels to a specific color, use the fill() method:
https://github.com/adafruit/Adafruit_Ne ... xel.h#L216
Also, don't forget to call show() to actually have the updated colors sent out to the NeoPixels.

adafruit_support_carter
 
Posts: 16400
Joined: Tue Nov 29, 2016 2:45 pm

Please be positive and constructive with your questions and comments.