Control an led and a led strip in one script.

Good Day, I am a newbee to this so please be patient with me. I have been successful in getting a small 9 led strip to fade in white repeatedly. What I am struggling with is adding the code for a red led on pin 3 and have it initialize on power to just simply blink on and off. while the led strip fades. Here is the code I have for the strip which works. What I need help with is adding the code to blink the red led and I do not have clue where to add it and in what order to make it function along with the strip of leds. Here is my code so far:
#include <Adafruit_NeoPixel.h>
#ifdef AVR
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif

#define PIN 2
#define NUMPIXELS 9

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + 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(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}

void loop() {
brighten();
darken();
}

// 0 to 255
void brighten() {
uint16_t i, j;

for (j = 45; j < 255; j++) {
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, j, j, j);
}
strip.show();
delay(10);
}
//delay(1500);
}

// 255 to 0
void darken() {
uint16_t i, j;

for (j = 255; j > 45; jā€“) {
for (i = 0; i < strip.numPixels(); i++) {
strip.setPixelColor(i, j, j, j);
}
strip.show();
delay(10);
}
delay(1500);
}

So can anyone advise what to add and where in the script?
Thank you in advance for your help.

You will need to get rid of those delays. Non-blocking timing tutorials:
Several things at a time.
Beginner's guide to millis().
Blink without delay().

Read the how get the most out of this forum sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code in code tags.

This topic was automatically closed after 120 days. New replies are no longer allowed.