i dont get this,
it should be working so this is probably something stupidly simple im missing.
the code below all works fine except for the impulse state and strobe2 stage.
everything else works fine.
i've tested with different leds, tested on different pin assignments, tested with a stand-alone digitalwrite high test and stand alone fade test and those both work without issues on the 2 pins in question (2 and 11)
so i dont understand why they are failing to operate in the code
i'd be greatful if someone can look over it/test it on their arduino uno and see if they can offer some help or resolve the issue.
it should be working so this is probably something stupidly simple im missing.
the code below all works fine except for the impulse state and strobe2 stage.
everything else works fine.
i've tested with different leds, tested on different pin assignments, tested with a stand-alone digitalwrite high test and stand alone fade test and those both work without issues on the 2 pins in question (2 and 11)
so i dont understand why they are failing to operate in the code
Rich (BB code):
// The Voyager
#include <LedFader.h>
#include <LedFlasher.h>
// pin assignments PMW 3,5,6,9,10,11
const byte StrobesPin = 1; //FLASH
const byte Strobes2Pin = 2; //FLASH
const byte NavigationPin = 7; //FLASH
const byte DeflectorPin = 6; //FADE
const byte NacellesPin = 9; //FADE
const byte ShuttlebayPin = 10; //FADE
const byte FloodlightPin = 8; //BLINK
const byte TorpedoPin = 4; //BLINK
const byte ImpulsePin = 11; //FADE
const byte CabinPin2 = 5; //FADE
const byte CabinPin1 = 3; //FADE
// Faders pin min max millis on? stop?
LedFader Cabin1Fader (CabinPin1, 0, 255, 3000, false, true);
LedFader Cabin2Fader (CabinPin2, 0, 80, 3000, false, true);
LedFader ShuttlebayFader (ShuttlebayPin, 0, 80, 3000, false, true);
LedFader FloodlightFader (FloodlightPin, 0, 255, 3000, false, true);
LedFader NacellesFader (NacellesPin, 0, 255, 3000, false, true);
LedFader DeflectorFader (DeflectorPin, 0, 255, 3000, false, true);
LedFader ImpulseFader (ImpulsePin, 0, 255, 3000, false, true);
LedFader TorpedoFader (TorpedoPin, 0, 255, 3000, false, true);
// Flashers pin off-time on-time on?
LedFlasher strobes (StrobesPin, 1900, 100, false);
LedFlasher strobes2 (Strobes2Pin, 900, 100, false);
LedFlasher navigation (NavigationPin, 500, 1500, false);
// states for the state machine
typedef enum
{
initialState,
//startup mode
wantCabin1startup,
wantCabin2startup,
wantShuttleBaystartup,
wantFloodlightstartup,
wantNacellesstartup,
wantImpulsestartup,
wantDeflectorstartup,
wantTorpedostartup,
wantNavigationstartup,
wantStrobestartup,
wantStrobe2startup,
}
states;
// state machine variables
states state = initialState;
unsigned long lastStateChange = 0;
unsigned long timeInThisState = 1000;
void setup ()
{
pinMode (CabinPin1, OUTPUT);
pinMode (CabinPin2, OUTPUT);
pinMode (ShuttlebayPin, OUTPUT);
pinMode (FloodlightPin, OUTPUT);
pinMode (NacellesPin, OUTPUT);
pinMode (ImpulsePin, OUTPUT);
pinMode (DeflectorPin, OUTPUT);
pinMode (TorpedoPin, OUTPUT);
pinMode (StrobesPin, OUTPUT);
pinMode (TorpedoPin, OUTPUT);
pinMode (StrobesPin, OUTPUT);
pinMode (Strobes2Pin, OUTPUT);
// set up faders, flashers
Cabin1Fader.begin ();
Cabin2Fader.begin ();
ShuttlebayFader.begin ();
FloodlightFader.begin ();
NacellesFader.begin ();
ImpulseFader.begin ();
DeflectorFader.begin ();
TorpedoFader.begin ();
strobes.begin ();
strobes2.begin ();
navigation.begin ();
} // end of setup
void doStateChange ()
{
lastStateChange = millis (); // when we last changed states
timeInThisState = 1000; // default one second between states
switch (state)
{
case initialState:
state = wantCabin1startup;
break;
case wantCabin1startup:
Cabin1Fader.on();
state = wantCabin2startup;
break;
case wantCabin2startup:
Cabin2Fader.on();
state = wantShuttleBaystartup;
break;
case wantShuttleBaystartup:
ShuttlebayFader.on();
state = wantFloodlightstartup;
break;
case wantFloodlightstartup:
digitalWrite(FloodlightPin, HIGH);
state = wantNacellesstartup;
break;
case wantNacellesstartup:
NacellesFader.on();
state = wantDeflectorstartup;
break;
case wantImpulsestartup:
ImpulseFader.on();
state = wantDeflectorstartup;
break;
case wantDeflectorstartup:
DeflectorFader.on();
state = wantTorpedostartup;
break;
case wantTorpedostartup:
digitalWrite(TorpedoPin, HIGH);
state = wantNavigationstartup;
break;
case wantNavigationstartup:
navigation.on();
state = wantStrobestartup;
break;
case wantStrobestartup:
strobes.on();
state = wantStrobes2on;
break;
case wantStrobe2startup:
strobes2.on();
break;
//impulse mode
} // end of switch on state
} // end of doStateChange
void loop ()
{
if (millis () - lastStateChange >= timeInThisState)
doStateChange ();
// update faders, flashers
Cabin1Fader.update ();
Cabin2Fader.update ();
ShuttlebayFader.update ();
FloodlightFader.update ();
DeflectorFader.update ();
NacellesFader.update ();
ImpulseFader.update ();
TorpedoFader.update ();
navigation.update ();
strobes.update ();
strobes2.update ();
// other stuff here like testing switches
} // end of loop