Hi all,
I wrote some simple code for a project to control an Neopixel RGB led panel. It works great but there is a delay when changing colors. Is there an easy way to speed this up so that it will react faster? Any suggestions would be great!
#include <Adafruit_NeoPixel.h>
#define PIN 7 //neopixel signal pin
#define NUMPIXELS 64 //number of neopixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
unsigned long ch1; //Channel input variable
unsigned long ch2;
unsigned long ch3;
void setup(){
pinMode(4, INPUT);//Setting put pin4 as a input
pinMode(5, INPUT);//Setting put pin5 as a input
pinMode(6, INPUT);//Setting put pin6 as a input
pixels.begin(); // This initializes the NeoPixel library
}
void loop(){
ch1 = pulseIn(4, HIGH); // Read the pulse width of channel 1
ch2 = pulseIn(5, HIGH); // Read the pulse width of channel 2
ch3 = pulseIn(6, HIGH); // Read the pulse width of channel 3
int Red = map(ch1, 0, 2500, 0, 255);
int Green = map(ch2, 0, 2500, 0, 255);
int Blue = map(ch3, 0, 2500, 0, 255);
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i,Red, Green, Blue);
}
pixels.show();
}