// SPDX-FileCopyrightText: 2018 Mikey Sklar for Adafruit Industries
//
// SPDX-License-Identifier: MIT
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 4
// Color Segments
#define APIXELS 21 // number of first orange pixels
#define BPIXELS 131 // number of blue pixels
#define CPIXELS 144 // second orange pixels
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(144, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 10; // delay for half a second
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.begin(); // This initializes the NeoPixel library.
}
void loop() {
// For the first 21 pixels, make them orange, starting from pixel number 0
for(int i=0;i<APIXELS;i++){
pixels.setPixelColor(i, pixels.Color(255,50,0)); // Set Pixels to Orange Color
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
// Fill up 110 pixels with blue, starting with pixel number 21.
for(int i=110;i<BPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(0,250,200)); // Set Pixels to Blue Color
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
// Fill up 13 pixels with orange, starting from pixel number 131.
for(int i=13;i<CPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(250,50,0)); //Set Pixels to Orange Color
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
Neopixel LED strip modified code from zelda sword project
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- dre_force
- Posts: 16
- Joined: Thu Oct 14, 2021 9:08 pm
- dre_force
- Posts: 16
- Joined: Thu Oct 14, 2021 9:08 pm
Re: Neopixel LED strip modified code from zelda sword projec
The code below i can get a maximum of 110 leds to light up orange. any number above 110 no leds light up.
i will try multi coloured now up to 110
// SPDX-FileCopyrightText: 2018 Mikey Sklar for Adafruit Industries
//
// SPDX-License-Identifier: MIT
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 4
// Color Segments
#define APIXELS 110 // number of first orange pixels
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(110, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 10; // delay for half a second
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.begin(); // This initializes the NeoPixel library.
}
void loop() {
// For the first 110 pixels, make them orange, starting from pixel number 0
for(int i=0;i<APIXELS;i++){
pixels.setPixelColor(i, pixels.Color(255,50,0)); // Set Pixels to Orange Color
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
i will try multi coloured now up to 110
// SPDX-FileCopyrightText: 2018 Mikey Sklar for Adafruit Industries
//
// SPDX-License-Identifier: MIT
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 4
// Color Segments
#define APIXELS 110 // number of first orange pixels
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(110, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 10; // delay for half a second
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.begin(); // This initializes the NeoPixel library.
}
void loop() {
// For the first 110 pixels, make them orange, starting from pixel number 0
for(int i=0;i<APIXELS;i++){
pixels.setPixelColor(i, pixels.Color(255,50,0)); // Set Pixels to Orange Color
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
- dre_force
- Posts: 16
- Joined: Thu Oct 14, 2021 9:08 pm
Re: Neopixel LED strip modified code from zelda sword projec
This code i get 21 orange and 89blue for a total of 110.
// SPDX-FileCopyrightText: 2018 Mikey Sklar for Adafruit Industries
//
// SPDX-License-Identifier: MIT
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 4
// Color Segments
#define APIXELS 21 // number of first orange pixels
#define BPIXELS 110 // number of blue pixels
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(110, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 10; // delay for half a second
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.begin(); // This initializes the NeoPixel library.
}
void loop() {
// For the first 21 pixels, make them orange, starting from pixel number 0.
for(int i=0;i<APIXELS;i++){
pixels.setPixelColor(i, pixels.Color(255,50,0)); // Set Pixels to Orange Color
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
// Fill up 110 pixels with blue, starting with pixel number 21.
for(int i=21;i<BPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(0,250,200)); // Set Pixels to Blue Color
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
// SPDX-FileCopyrightText: 2018 Mikey Sklar for Adafruit Industries
//
// SPDX-License-Identifier: MIT
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 4
// Color Segments
#define APIXELS 21 // number of first orange pixels
#define BPIXELS 110 // number of blue pixels
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(110, PIN, NEO_GRB + NEO_KHZ800);
int delayval = 10; // delay for half a second
void setup() {
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
pixels.begin(); // This initializes the NeoPixel library.
}
void loop() {
// For the first 21 pixels, make them orange, starting from pixel number 0.
for(int i=0;i<APIXELS;i++){
pixels.setPixelColor(i, pixels.Color(255,50,0)); // Set Pixels to Orange Color
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
// Fill up 110 pixels with blue, starting with pixel number 21.
for(int i=21;i<BPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(0,250,200)); // Set Pixels to Blue Color
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
- dre_force
- Posts: 16
- Joined: Thu Oct 14, 2021 9:08 pm
Re: Neopixel LED strip modified code from zelda sword projec
110 seem to be the maximum amount of leds i can get to light up manipulating this code.
- dre_force
- Posts: 16
- Joined: Thu Oct 14, 2021 9:08 pm
Re: Neopixel LED strip modified code from zelda sword projec
looking a bit better but would be ideal to get those last leds lit up.
- Attachments
-
- IMG_20211019_202334.jpeg (238.32 KiB) Viewed 94 times
- dre_force
- Posts: 16
- Joined: Thu Oct 14, 2021 9:08 pm
Re: Neopixel LED strip modified code from zelda sword projec
My initially try i did use the trinket Mo but could not power the leds at all, i belive the led strip requires 5v and the Mo only provides 3v out I could use a buck booster to up from 3-5v but that will add an additional board which is why i switched to the trinket 5v.dastels wrote:First, consider upgrading to a Trinket M0. The older Trinket models are known to have problems with more modern USB implementations. There's a warning to that effect on the product page.
Secondly, your for loops are still incorrect. Please reread my previous responses regarding the code.
Dave
i give this a go next anyway
- dastels
- Posts: 15653
- Joined: Tue Oct 20, 2015 3:22 pm
Re: Neopixel LED strip modified code from zelda sword projec
NeoPixels will work fine (but not quite as bright) on 3.3v, but many pixels could be a challenge for the Trinket's regulator 3.3v regulator. In the original circuit the pixels are being powered directly by the battery. So you are right that a 5v data signal would work better (since the pixels will be powered with 3.7-4.2v from the battery. With a TrinketM0 you'll likely need a level shifter for the data signal. However, that's all irrelevant to the potential/likely issue of not being able to reliably program the Trinket.
In your code, you create the NoePixel object to have 110 pixels:
As such, it will never use more than 110 pixels. Or do you mean that increasing that number still won't light more. Or if you increase it does it not light any?
Can you paste the last few lines of the build output? The part that says how much memory the code is using... especially ram/heap.
Dave
In your code, you create the NoePixel object to have 110 pixels:
Code: Select all
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(110, PIN, NEO_GRB + NEO_KHZ800);
Can you paste the last few lines of the build output? The part that says how much memory the code is using... especially ram/heap.
Dave
- dre_force
- Posts: 16
- Joined: Thu Oct 14, 2021 9:08 pm
Re: Neopixel LED strip modified code from zelda sword projec
if i up the 110 number in the line below any number above 110 no leds light up. all numbers before 110 work as programmed.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(110, PIN, NEO_GRB + NEO_KHZ800);
The last couple lines of the build output-
Sketch uses 2294 bytes (43%) of program storage soace. Maximum is 5310 bytes.
Global variables use 40 bytes of dynamic memory.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(110, PIN, NEO_GRB + NEO_KHZ800);
The last couple lines of the build output-
Sketch uses 2294 bytes (43%) of program storage soace. Maximum is 5310 bytes.
Global variables use 40 bytes of dynamic memory.
Please be positive and constructive with your questions and comments.