GForce2010
Member
Hi.
I've had a search on here but couldn't find the answer to my question.
This is my first time using a Teensy and I only know enough about coding to be dangerous so apologies if I am making some stupid mistake.
I am working on a project that needs lights and sound, after some research I decided to try a Teensy 4.0 with the Rev D audio board and some Neopixels.
I'm just at the stage of connecting bits together on a breadboard and getting some basic code running.
I am using a 74ahct125 between the Teensy and the pixels.
I downloaded the WS2812Serial - Non-Blocking WS2812B / NeoPixel LEDs Library and loaded and started playing with the examples.
After a bit of time i realised that the 7 pixels i had running seems to be updating slower than I remembered when using them with a Arduino.
I wrote some code that lights all the pixels at full red then dims it, from 255 - 0, without adding any delays.
The results were that my Arduino Nano is able to light and dim the 7 pixels around 8 times a second whereas the simular code running on the Teensy can only do the same around twice a second.
If there were and differences I would have expected the Teensy to be faster that the Nano rather than the other way round.
Is this some limitation on the non-blocking library or do I have a problem somewhere?
Program running on the Teensy.
Program running on the Nano.
Any help of tips greatly appreciated.
Thanks.
I've had a search on here but couldn't find the answer to my question.
This is my first time using a Teensy and I only know enough about coding to be dangerous so apologies if I am making some stupid mistake.
I am working on a project that needs lights and sound, after some research I decided to try a Teensy 4.0 with the Rev D audio board and some Neopixels.
I'm just at the stage of connecting bits together on a breadboard and getting some basic code running.
I am using a 74ahct125 between the Teensy and the pixels.
I downloaded the WS2812Serial - Non-Blocking WS2812B / NeoPixel LEDs Library and loaded and started playing with the examples.
After a bit of time i realised that the 7 pixels i had running seems to be updating slower than I remembered when using them with a Arduino.
I wrote some code that lights all the pixels at full red then dims it, from 255 - 0, without adding any delays.
The results were that my Arduino Nano is able to light and dim the 7 pixels around 8 times a second whereas the simular code running on the Teensy can only do the same around twice a second.
If there were and differences I would have expected the Teensy to be faster that the Nano rather than the other way round.
Is this some limitation on the non-blocking library or do I have a problem somewhere?
Program running on the Teensy.
Code:
#include "Arduino.h"
#include <WS2812Serial.h>
const int numled = 7;
const int pin = 1;
byte drawingMemory[numled*3]; // 3 bytes per LED
DMAMEM byte displayMemory[numled*12]; // 12 bytes per LED
WS2812Serial leds(numled, displayMemory, drawingMemory, pin, WS2812_GRB);
void setup() {
leds.begin();
}
void test(int hue) {
for(int i=0;i<leds.numPixels();i++){
leds.setPixel(i, hue,0,0);
}
leds.show();
}
void loop() {
for(int i=255;i>=0;i--){
test(i);
}
}
Program running on the Nano.
Code:
#include <Adafruit_NeoPixel.h>
#define PIN 3
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 7
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pixels.begin(); // This initializes the NeoPixel library.
}
void loop() {
for(int i=255;i>=0;i--){
test(i);
}
}
void test(int hue) {
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(hue,0,0));
}
pixels.show(); // This sends the updated pixel color to the hardware.
}
Any help of tips greatly appreciated.
Thanks.