Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

noob questions
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

noob questions

by thelearnlaxi on Sat Jun 06, 2020 7:30 am

so i'm extremely new to coding and i'm REALLY enjoying playing with my new Beetle. I've got a code I put together for a Destiny Ghost shell I'm making. I would like to add in a fade effect the the center of the ghosts eye that takes the set color and dims it to half then ramps back up to full. I've been looking around and everything I try I end up loosing my running light colors. Any pointer are welcome. sorry if this seems silly. here is the code i Have so far with out the fade.

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>

#define PIN 9  //Which pin the pixels are connected to
#define LED_COUNT 6  //Number of pixels used

// Create an instance of the Adafruit_NeoPixel class called "leds".
// That'll be what we refer to from here on...
Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);

void setup()
{
 leds.begin();  // Start up the LED strip
 leds.show();   // LEDs don't actually update until you call this function
}

void loop()
{
   
  leds.setPixelColor(0, 255, 0, 0); // Set the running light top right
  leds.setPixelColor(1, 255, 0, 0); // Set the running light bottom right
  leds.setPixelColor(2, 255, 0, 255); // Set the center eye right
  leds.setPixelColor(3, 255, 0, 255); // Set the center eye left
  leds.setPixelColor(4, 255, 0, 0); // Set the running light bottom left
  leds.setPixelColor(5, 255, 0, 0); // Set the running light top left
  leds.show(); //Display the colors
}


setpixelcolor(2
setpixelcolor(3
are the codes I'm looking to fade without altering the others.

thelearnlaxi
 
Posts: 3
Joined: Sat Nov 16, 2019 3:29 am

Re: noob questions

by adafruit_support_bill on Sat Jun 06, 2020 7:43 am

If you want the other pixels to remain constant, set them in your setup() function. If you don't change them in your loop function, they will remain the same.

In your loop, eliminate all the code related to the running lights and just fade pixels 2 and 3.

adafruit_support_bill
 
Posts: 78633
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.