Newbie here so don't crucify me please!
Using an Arduino Nano.
I have looked, read and studied a lot of code and this is what I have thus far. It works for what I would like but, there are a few things I want to add, however, not sure how to do it, thus I am asking for some input/help.
Key thing I would like to do, is to be able to make the MainChaser (scanner lights) to be controlled by a On/Off button. I can not seem to quite figure that out.
The other is that I would like to have a secondary button simply turn an LED on and off. No delays or millis, just plain on or off.
I have pins 2, 9 and 13 still available for all of this.
Any help is appreciated.
Here is what I have:
const int MainChaser[] = {
6,5,4,3}; // front scanner center out
const int Chaser_Count = sizeof MainChaser / sizeof (int);
const int ChaserIntervals[] =
{
140, 140, 140, 140}
; // Milliseconds
unsigned long ChaserTime = millis();
int ChaserStep = 0;
const int Library[] = {
10,11,12}; //alpha , beta, gamma, delta
const int Library_Count = sizeof Library / sizeof (int);
const int Library_Intervals[] = {
400, 400, 400}
; // Milliseconds
unsigned long LibraryTime = millis();
int LibraryStep = 0;
const int Temp[] = {
7,8}; //front two above scanner
const int Temp_Count = sizeof Temp / sizeof (int);
const int Temp_Intervals[] = {
1000, 1000}
; // Milliseconds
unsigned long TempTime = millis();
int TempStep = 0;
void setup()
{
int i;
/* Chaser LED's */
for (i=0; i< Chaser_Count; i++)
pinMode(MainChaser[i], OUTPUT); // Yes, it's OK to set the pinMode twice on some pins
/* Library LED's */
for (i=0; i< Library_Count; i++)
pinMode(Library[i], OUTPUT);
/* Temp LED's */
for (i=0; i< Temp_Count; i++)
pinMode(Temp[i], OUTPUT);
}
void loop()
{
// Do the chaser animation - front scanner
if ((millis() - ChaserTime) > ChaserIntervals[ChaserStep])
{
ChaserTime = millis();
digitalWrite(MainChaser[ChaserStep], LOW);
ChaserStep = (ChaserStep+1) % Chaser_Count;
digitalWrite(MainChaser[ChaserStep], HIGH);
}
// Do the library animation - alpha , beta, gamma, delta
if ((millis() - LibraryTime) > Library_Intervals[LibraryStep])
{
LibraryTime = millis();
digitalWrite(Library[LibraryStep], LOW);
LibraryStep = (LibraryStep+1) % Library_Count;
digitalWrite(Library[LibraryStep], HIGH);
}
// Do the Temp animation
if ((millis() - TempTime) > Temp_Intervals[TempStep])
{
TempTime = millis();
digitalWrite(Temp[TempStep], LOW);
TempStep = (TempStep+1) % Temp_Count;
digitalWrite(Temp[TempStep], HIGH);
}
}