So, here is the code I am currently using...
int R = 2;
int I = 3;
int C = 4;
int K = 5;
int Y = 6;
int D = 7;
int A = 8;
int L = 9;
int E = 10;
const int select = 13;
const int maxScene = 3;
int scene = 0;
void setup() {
pinMode(select, INPUT_PULLUP);
pinMode(R, OUTPUT);
pinMode(I, OUTPUT);
pinMode(C, OUTPUT);
pinMode(K, OUTPUT);
pinMode(Y, OUTPUT);
pinMode(D, OUTPUT);
pinMode(A, OUTPUT);
pinMode(L, OUTPUT);
pinMode(E, OUTPUT);
Serial.begin (9600);
}
void loop() {
switch (scene) {
case 0:
digitalWrite(R, LOW);
digitalWrite(I, LOW);
digitalWrite(C, LOW);
digitalWrite(K, LOW);
digitalWrite(Y, LOW);
digitalWrite(D, LOW);
digitalWrite(A, LOW);
digitalWrite(L, LOW);
digitalWrite(E, LOW);
delay(50);
digitalWrite(R, HIGH);
myDelay (100);
digitalWrite(R, LOW);
myDelay (100);
digitalWrite(I, HIGH);
myDelay (100);
digitalWrite(I, LOW);
myDelay (100);
digitalWrite(C, HIGH);
myDelay (100);
digitalWrite(C, LOW);
myDelay (100);
digitalWrite(K, HIGH);
myDelay (100);
digitalWrite(K, LOW);
myDelay (100);
digitalWrite(Y, HIGH);
myDelay (100);
digitalWrite(Y, LOW);
myDelay (100);
digitalWrite(D, HIGH);
myDelay (100);
digitalWrite(D, LOW);
myDelay (100);
digitalWrite(A, HIGH);
myDelay (100);
digitalWrite(A, LOW);
myDelay (100);
digitalWrite(L, HIGH);
myDelay (100);
digitalWrite(L, LOW);
myDelay (100);
digitalWrite(E, HIGH);
myDelay (100);
digitalWrite(E, LOW);
myDelay (100);
break;
case 1:
digitalWrite(R, HIGH);
myDelay(100);
digitalWrite(R, LOW);
myDelay(100);
digitalWrite(I, HIGH);
myDelay(100);
digitalWrite(I, LOW);
myDelay(100);
digitalWrite(C, HIGH);
myDelay(100);
digitalWrite(C, LOW);
myDelay(100);
digitalWrite(K, HIGH);
myDelay(100);
digitalWrite(K, LOW);
myDelay(100);
digitalWrite(Y, HIGH);
myDelay(100);
digitalWrite(Y, LOW);
myDelay(100);
digitalWrite(D, HIGH);
myDelay(100);
digitalWrite(D, LOW);
myDelay(100);
digitalWrite(A, HIGH);
myDelay(100);
digitalWrite(A, LOW);
myDelay(100);
digitalWrite(L, HIGH);
myDelay(100);
digitalWrite(L, LOW);
myDelay(100);
digitalWrite(E, HIGH);
myDelay(100);
digitalWrite(E, LOW);
myDelay(100);
digitalWrite(L, HIGH);
myDelay(100);
digitalWrite(L, LOW);
myDelay(100);
digitalWrite(A, HIGH);
myDelay(100);
digitalWrite(A, LOW);
myDelay(100);
digitalWrite(D, HIGH);
myDelay(100);
digitalWrite(D, LOW);
myDelay(100);
digitalWrite(Y, HIGH);
myDelay(100);
digitalWrite(Y, LOW);
myDelay(100);
digitalWrite(K, HIGH);
myDelay(100);
digitalWrite(K, LOW);
myDelay(100);
digitalWrite(C, HIGH);
myDelay(100);
digitalWrite(C, LOW);
myDelay(100);
digitalWrite(I, HIGH);
myDelay(100);
digitalWrite(I, LOW);
myDelay(100);
break;
case 2:
digitalWrite(R, HIGH);
digitalWrite(E, HIGH);
myDelay(100);
digitalWrite(R, LOW);
digitalWrite(E, LOW);
myDelay(100);
digitalWrite(I, HIGH);
digitalWrite(L, HIGH);
myDelay(100);
digitalWrite(I, LOW);
digitalWrite(L, LOW);
myDelay(100);
digitalWrite(C, HIGH);
digitalWrite(A, HIGH);
myDelay(100);
digitalWrite(C, LOW);
digitalWrite(A, LOW);
myDelay(100);
digitalWrite(K, HIGH);
digitalWrite(D, HIGH);
myDelay(100);
digitalWrite(K, LOW);
digitalWrite(D, LOW);
myDelay(100);
digitalWrite(Y, HIGH);
myDelay(100);
digitalWrite(Y, LOW);
myDelay(100);
digitalWrite(K, HIGH);
digitalWrite(D, HIGH);
myDelay(100);
digitalWrite(K, LOW);
digitalWrite(D, LOW);
myDelay(100);
digitalWrite(C, HIGH);
digitalWrite(A, HIGH);
myDelay(100);
digitalWrite(C, LOW);
digitalWrite(A, LOW);
myDelay(100);
digitalWrite(I, HIGH);
digitalWrite(L, HIGH);
myDelay(100);
digitalWrite(I, LOW);
digitalWrite(L, LOW);
myDelay(100);
break;
case 3:
digitalWrite(D, HIGH);
digitalWrite(A, HIGH);
digitalWrite(L, HIGH);
digitalWrite(E, HIGH);
digitalWrite(R, HIGH);
digitalWrite(I, HIGH);
digitalWrite(C, HIGH);
digitalWrite(K, HIGH);
digitalWrite(Y, HIGH);
myDelay(500);
digitalWrite(R, LOW);
digitalWrite(I, LOW);
digitalWrite(C, LOW);
digitalWrite(K, LOW);
digitalWrite(Y, LOW);
myDelay(500);
break;
}
}
void myDelay(int delayTime) {
if (digitalRead(select) == LOW)
Serial.println ("Scene Change");
{
scene++;
if (scene > maxScene) {
scene = 0;
}
}
delay(delayTime);
}
I wrote this, and tested it using an Uno and a breadboard. I had everything working flawlessly.
Well, on my final product, I am using a Nano. The code uploads fine, but once it starts, it glitches out. It runs case 0 one time, then goes to case 2, and will not change from there. I have tested my connections with a meter, and everything is good there.
I added in the Serial lines in hopes I could see when the button is pressed.
}
void myDelay(int delayTime) {
if (digitalRead(select) == LOW)
Serial.println ("Scene Change");
{
scene++;
if (scene > maxScene) {
scene = 0;
}
}
delay(delayTime);
}
When it is set to High, I get no feedback on the serial monitor. When it is set to low, I get constant feedback.
My only thought is that I am powering it off of my laptop right now, and the supply voltage may not be enough.
Anyone see something that I dont?