Neopixel Doesn't work when changing codes

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Erit1566
 
Posts: 6
Joined: Fri Jul 20, 2018 8:47 pm

Neopixel Doesn't work when changing codes

Post by Erit1566 »

Hello, I have 2 neopixel rings hooked up to an arduino nano. I have 2 different codes, the example sketch, and the code i am trying to implement it. When I put the example code, Copy paste, into the new code, no leds light.
20180923_132142.jpg
20180923_132142.jpg (70.26 KiB) Viewed 153 times
Here is the first example code:

Code: Select all

// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the Neobig?
// On a Trinket or Gemma we suggest changing this to 1
#define bigPIN            11
#define smallPIN            12
// How many Neobig are attached to the Arduino?
#define NUMbig      24

// When we setup the NeoPixel library, we tell it how many big, 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 big = Adafruit_NeoPixel(NUMbig, bigPIN, NEO_GRBW + NEO_KHZ800);
Adafruit_NeoPixel small = Adafruit_NeoPixel(NUMbig, smallPIN, NEO_GRB + NEO_KHZ800);

int delayval = 50; // 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

  big.begin(); // This initializes the NeoPixel library.
  small.begin();
}

void loop() {

  // For a set of Neobig the first NeoPixel is 0, second is 1, all the way up to the count of big minus one.

  for(int i=0;i<NUMbig;i++){

    // big.Color takes RGB values, from 0,0,0 up to 255,255,255
    big.setPixelColor(i, big.Color(0,10,0)); // Moderately bright green color.
    small.setPixelColor(i, big.Color(0,0,10));
    big.show(); // This sends the updated small color to the hardware.
    small.show();
    delay(delayval); // Delay for a period of time (in milliseconds).

  }
}

Here is the code I am trying to implement it

Code: Select all

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define bigPIN  11
#define smallPIN  12

#define NUMbig      48
#define NUMsmall       48

#define BRIGHTNESS 50

Adafruit_NeoPixel big = Adafruit_NeoPixel(NUMbig, bigPIN, NEO_GRBW + NEO_KHZ800);
Adafruit_NeoPixel small = Adafruit_NeoPixel(NUMsmall, smallPIN, NEO_GRB + NEO_KHZ800);

 int counter = 0;
 
char t[10]={};
const byte SLAVE_ADDRESS = 8;

int selectPin = 3;

int lastValue1 = 0;

int arrays[128];

long encval;

bool oldState = HIGH;

int casario;

int cased;
int cases;

int pbr;
int pbg;
int pbb;

int psr;
int psg;
int psb;
  
int x = 0;

int createdEnc = 0;
int nowEnc = 0;

void setup()   {     
  delay(500);
  Serial.begin(9600);
  Serial.println("Starting Setup");
  Serial.println("Setting Up Pins");
  Wire.begin(SLAVE_ADDRESS);
  Serial.print("=");
  

  pinMode(selectPin,INPUT_PULLUP);
  Serial.print("=");
//  pinMode(clearPin,INPUT_PULLUP); 
//  Serial.print("=");
  
//  attachInterrupt(digitalPinToInterrupt(clearPin),Clear,HIGH);  
  Serial.println("Finished Setting Up Pins");
  
  Serial.println("Starting Screen");
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  delay(500);
  // Clear the buffer.
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.print("Starting Up");
  display.display();
  delay(500);
  Serial.println("Finished setting up screen");

  #if defined (__AVR_ATtiny85__)
  if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
  // End of trinket special code
  Serial.println("Starting Setting up LEDS");
//  small.setBrightness(BRIGHTNESS);
//  big.setBrightness(BRIGHTNESS);
  big.begin(); 
  small.begin();
  big.show();
  small.show();
  Serial.println("Finished Setting Up LEDS");
  Serial.println("Finished Setup");

//  cross(255,0,0,50);
//  cross(0,0,0,50);
//  display.display();
//  eyes();
//  encRes();
  
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop(){
// selection();
//  picker();
  //averageRGB();
// requestEncoder();
  for(int i=0;i<48;i++){

    // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
    big.setPixelColor(i, big.Color(0,10,0)); // Moderately bright green color.
    small.setPixelColor(i, small.Color(0,0,10));
    big.show(); // This sends the updated pixel color to the hardware.
    small.show();
    delay(50);
  
}
}
I know my code is horrible, I will comment it and everything when I am done with figuring it all out. I'm open to all suggestions. Thanks for all of your help.
-Eric

User avatar
Franklin97355
 
Posts: 23910
Joined: Mon Apr 21, 2008 2:33 pm

Re: Neopixel Doesn't work when changing codes

Post by Franklin97355 »

Code: Select all

#define bigPIN  11
#define smallPIN  12
These pins are used by SPI. You should pick some other pins for these.

User avatar
Erit1566
 
Posts: 6
Joined: Fri Jul 20, 2018 8:47 pm

Re: Neopixel Doesn't work when changing codes

Post by Erit1566 »

I switched them them to pin 6 and 7. On the simple code it both work fine but on the main code the small led ring is now working but the large one is still not.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”