I think I placed all the correct coding where it should be, however the leds won't light. If I use "void loop" the leds just run continuously once the board has power. If i use only "loop" they aren't triggered when the input pin receives a HIGH charge. I didn't put the new code into the project as i wanted to test it first. i have second board just for testing this new code and the leds. i have two Neopixel bars connected ( i know they work because i tried a regular code prior to this and they run fine).
Right now for testing i have my neopixels hooked up to the Uno's Gnd/5v and PIN 11. I am jumping a line from the 5v to any digital input 0-4 as they are the inputs i use to receive the RF trasmitter trigger. i am hoping you can see where i made my mistake. please let me know if you need pics or something to help you decipher my setup. below is the full code. I really appreciate any help you can offer. Thanks in advance.
Code: Select all
//2015 TV Stand and Controller Control
#include <Adafruit_NeoPixel.h>
const int Relay1 = 7;
const int Relay2 = 6;
const int Relay3 = 5;
const int Relay4 = 4;
int Relay1a = 8;
int Relay2a = 9;
int Relay3a = 10;
int Relay4a = 11;
const int buttonPin0 = 0;
const int buttonPin1 = 1;
const int buttonPin2 = 2;
const int buttonPin3 = 3;
int buttonState0 = 0;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
#define PIN 12
#define TPIXEL 16
int wait_T=40;
int PixelCount=16;
int Pixel_Start_End=0;
boolean UsingBar = true;//true is for 3 LEDs & false is for 5 LEDs
long start = millis();//gets the start time
Adafruit_NeoPixel strip = Adafruit_NeoPixel(TPIXEL, PIN, NEO_GRB + NEO_KHZ800);
// the setup routine runs once when you press reset:
void setup() {
pinMode(buttonPin0, INPUT);
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(Relay3, OUTPUT);
pinMode(Relay4, OUTPUT);
pinMode(Relay1a, OUTPUT);
pinMode(Relay2a, OUTPUT);
pinMode(Relay3a, OUTPUT);
pinMode(Relay4a, OUTPUT);
strip.begin();
strip.show();
}
void loop () {
buttonState0 = digitalRead(buttonPin0);//Keyfob D
buttonState1 = digitalRead(buttonPin1);//Keyfob C
buttonState2 = digitalRead(buttonPin2);//Keyfob B
buttonState3 = digitalRead(buttonPin3);//Keyfob A
if (buttonState3 == HIGH) {
digitalWrite(Relay1,HIGH);//Actuator Lift Segment Up
delay(22000);
digitalWrite(Relay1,LOW);
}
while (millis() - start < 22000){//Should Run Knight Rider Bar for open duration
loop(); {
//Example: CylonEyeUp(Center_Dot_Color, Second_Dot_color, Third_Dot_color, wait_T, PixelCount, Pixel_Start_End);
CylonEyeUp(strip.Color(0,100,0), strip.Color(0,0,40), strip.Color(0,0,15), wait_T, PixelCount, Pixel_Start_End);
delay(wait_T);
//Example: CylonEyeDown(Center_Dot_Color, Second_Dot_color, Third_Dot_color, wait_T, PixelCount, Pixel_Start_End);
CylonEyeDown(strip.Color(0,100,0), strip.Color(0,0,40), strip.Color(0,0,15), wait_T, PixelCount, Pixel_Start_End);
delay(wait_T);
}
}
if (buttonState3 == LOW){
}
if (buttonState2 == HIGH) {
digitalWrite(Relay2,HIGH);//
delay(23000);
digitalWrite(Relay2,LOW);
}
while (millis() - start < 23000){//SHould run Knight Rider Bar during close duration
loop(); {
//Example: CylonEyeUp(Center_Dot_Color, Second_Dot_color, Third_Dot_color, wait_T, PixelCount, Pixel_Start_End);
CylonEyeUp(strip.Color(0,100,0), strip.Color(0,0,40), strip.Color(0,0,15), wait_T, PixelCount, Pixel_Start_End);
delay(wait_T);
//Example: CylonEyeDown(Center_Dot_Color, Second_Dot_color, Third_Dot_color, wait_T, PixelCount, Pixel_Start_End);
CylonEyeDown(strip.Color(0,100,0), strip.Color(0,0,40), strip.Color(0,0,15), wait_T, PixelCount, Pixel_Start_End);
delay(wait_T);
}
}
if (buttonState2 == LOW);{
}
if (buttonState1 == HIGH) {
digitalWrite(Relay1a, HIGH);//XBox Controller Tray
delay(1000);
digitalWrite(Relay1a, LOW);
delay(10000);
digitalWrite(Relay2a, HIGH);
delay(1000);
digitalWrite(Relay2a,LOW);
}
if (buttonState0 == HIGH){
digitalWrite(Relay3a, HIGH);//Remote Control Tray
delay(1000);
digitalWrite(Relay3a, LOW);
delay(10000);
digitalWrite(Relay4a, HIGH);
delay(1000);
digitalWrite(Relay4a, LOW);
}
}
void CylonEyeUp(uint32_t Co, uint32_t Ct, uint32_t Ctt, uint8_t Delay, int TotalPixels, int pStart) {
for(int i=pStart; i<TotalPixels; i++) {
if(!UsingBar) { strip.setPixelColor(i+2, Ctt); } //Third Dot Color
strip.setPixelColor(i+1, Ct); //Second Dot Color
strip.setPixelColor(i, Co); //Center Dot Color
strip.setPixelColor(i-1, Ct); //Second Dot Color
if(!UsingBar) { strip.setPixelColor(i-2, Ctt); } //Third Dot Color
if(!UsingBar) {
strip.setPixelColor(i-3, strip.Color(0,0,0)); //Clears the dots after the 3rd color
} else {
strip.setPixelColor(i-2, strip.Color(0,0,0)); //Clears the dots after the 2rd color
}
strip.show();
//Serial.println(i); //Used For pixel Count Debugging
delay(Delay);
}
}
void CylonEyeDown(uint32_t Co, uint32_t Ct, uint32_t Ctt, uint8_t Delay, int TotalPixels, int pEnd) {
for(int i=TotalPixels-1; i>pEnd; i--) {
if(!UsingBar) { strip.setPixelColor(i-2, Ctt); } //Third Dot Color
strip.setPixelColor(i-1, Ct); //Second Dot Color
strip.setPixelColor(i, Co); //Center Dot Color
strip.setPixelColor(i+1, Ct); //Second Dot Color
if(!UsingBar) { strip.setPixelColor(i+2, Ctt); } //Third Dot Color
if(!UsingBar) {
strip.setPixelColor(i+3, strip.Color(0,0,0)); //Clears the dots after the 3rd color
} else {
strip.setPixelColor(i+2, strip.Color(0,0,0)); //Clears the dots after the 2rd color
}
strip.show();
//Serial.println(i); //Used For pixel Count Debugging
delay(Delay);
}
}