0

Need help addressing NeoPixels with Arduino
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Need help addressing NeoPixels with Arduino

by jpeterswa on Fri Sep 17, 2021 6:01 pm

Hi there,
Thanks in advance for the assistance! This question relates to the Circuit Playground Express. I see the NeoPixels are on pin 8, at least I think it's 8 (the pinout diagram is fairly blurry and difficult to read). How can I turn these pixels on and off and set the color without using the cpp libraries? Our class is learning about pinMode and digitalRead, digitalWrite and these types of low level commands and I'd like them to be able to control the NeoPixels. So far we've just turned the red led on pin 13 on and off, which is not super exciting. What syntax do I need to use in the Arduino IDE?
Thanks!!

jpeterswa
 
Posts: 3
Joined: Fri Sep 17, 2021 5:58 pm

Re: Need help addressing NeoPixels with Arduino

by dastels on Fri Sep 17, 2021 6:43 pm

See https://learn.adafruit.com/adafruit-circuit-playground-express/pinouts for details on all (external and internal) pin usage.I don't know what pinout diagram you're looking at, but the one one the linked page is sharp and clear.

But, yes, the neopixels are on digital pin 8.

You need to use the libraries. The signal protocol to control the NeoPixels is involved and has rather tight timing constraints. If you look at the library (https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.cpp) you'll see that the show() function does the work of actually sending data to the pixels, and it's either some rather hacky timing tricks and/or written in assembly for some processors.

If you want to show using the digital pin functions, you can use the LED on pin 13. It's a simple LED and doing digitalWrites will control it.

Dave

dastels
 
Posts: 7525
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need help addressing NeoPixels with Arduino

by jpeterswa on Fri Sep 17, 2021 8:28 pm

Thank you Dave.
Am I on the right track with this code? It compiled and ran on the board but didn't light anything up. I think I need to find the documentation on this library to see what syntax it is looking for.
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>

int red=125;
int green=50;
int blue=55;
void setup() {
  // put your setup code here, to run once:
}
void loop() {
  CircuitPlayground.setPixelColor(0,red,green,blue);
  delay(100);
}

jpeterswa
 
Posts: 3
Joined: Fri Sep 17, 2021 5:58 pm

Re: Need help addressing NeoPixels with Arduino

by dastels on Fri Sep 17, 2021 8:38 pm

You need:
Code: Select all | TOGGLE FULL SIZE
CircuitPlayground.begin();

in your setup() function.

Dave

dastels
 
Posts: 7525
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need help addressing NeoPixels with Arduino

by jpeterswa on Fri Sep 17, 2021 8:51 pm

Hooray! It works! I can't thank you enough.

jpeterswa
 
Posts: 3
Joined: Fri Sep 17, 2021 5:58 pm

Please be positive and constructive with your questions and comments.