Need help addressing NeoPixels with Arduino

This is a special forum devoted to educators using Adafruit and Arduino products for teaching.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
jpeterswa
 
Posts: 6
Joined: Fri Sep 17, 2021 5:58 pm

Need help addressing NeoPixels with Arduino

Post by jpeterswa »

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!!

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need help addressing NeoPixels with Arduino

Post by dastels »

See https://learn.adafruit.com/adafruit-cir ... ss/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_Ne ... oPixel.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

User avatar
jpeterswa
 
Posts: 6
Joined: Fri Sep 17, 2021 5:58 pm

Re: Need help addressing NeoPixels with Arduino

Post by jpeterswa »

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

#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);
}

User avatar
dastels
 
Posts: 15656
Joined: Tue Oct 20, 2015 3:22 pm

Re: Need help addressing NeoPixels with Arduino

Post by dastels »

You need:

Code: Select all

CircuitPlayground.begin();
in your setup() function.

Dave

User avatar
jpeterswa
 
Posts: 6
Joined: Fri Sep 17, 2021 5:58 pm

Re: Need help addressing NeoPixels with Arduino

Post by jpeterswa »

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

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

Return to “For Educators”