not really well rested. tenants above us was banging and crashing around all night so a little slow today. but managable.

groove thats not really helping. and if anything it makes more sense than blink without delay.
the problem i have with millis is i dont know its full capabilities or now to use them yet.
henry, i have changed the delay code to 6 line of delay(10), and set the State in the chaser sequence values to true,
This resolved the problem shown in both videos of the delay causing problems. However, I'm going to look at using your idea instead of the 6 lines of delay.
I have also had to rethink the pin outputs.
Originally i was going to use RGB leds in the impulse engine, nacells and deflector dish. But when i was reading around and cleaning up the pin assignments i realised i would have to use shiftregisters or something due to the lack of pins. and this would make my head spin off.
So instead i am going to use 2 leds. It also makes more sense because the fading leds are like this:
impulse engine = red and orange
deflector dish = blue and orange
nacelles = blue and violet.
Now you can buy violet leds and as each thing only fades between 2 colours it just made sense. The down side to this is, I will have to tie in the cabin lights (primary and secondary) and the flood lights into some kind of 555 based timer circuit to have them come on at specific times and being triggered from 1 pin. This isnt a problem as these come on in the first sequence and just stay on until shut down.
The other down side is im loosing the torpedo fade and RCS fade. but i dont think the studio model has those changing brightness between modes anyway so its a little more accurate.
The new pin assignments are:
cabins, 1 //this is the primary, secondary and floodlights
rcs,2
torpedos,4
shuttlebaydoors, 7 //about the only thing that HASNT changed
shuttlebay, 8
impulsered, 3
impulseorange, 5
nacellsviolet, 6
nacellesblue, 9
deflectororange, 10
deflectorblue, 11
navigation, 12
strobes, 13
The final change was the shuttlebay room lights and the shuttlebay landing strips will also be on their own hardware based controller but triggered by a signal from pin 8.
Here is my code with those changes in effect, Its still fairly messy but a little bit cleaner.
void setup(){
setupChaser();
setupFade();
setupBlink();
}
void loop(){
loopChaser();
loopFade();
loopBlink();
}
long sequenceDelay = 1000;
boolean Primarystate = false;
boolean Secondarystate = false;
boolean Shuttlebaystate = false;
boolean Floodlightstate = false;
long waitUntilShuttlebay = sequenceDelay*2;
long waitUntilFloodlight = sequenceDelay*3;
long waitUntillPrimary = 0;
long waitUntillSecondary = sequenceDelay;
//definitions for fade
int impulsered = 3;
int impulseblue = 5;
int nacellsviolet = 6;
int nacellsblue = 9;
int deflectororange = 10;
int deflectorblue = 11;
int brightness = 100;
int fadeAmount = 5;
//definitions for blink and strobe
const byte strobe = 13;
const byte navigation = 12;
byte strobeState = LOW;
byte navigationState = LOW;
unsigned long previousMillis_1 = 0;
unsigned long previousMillis_2 = 0;
unsigned long nextInterval_1;
unsigned long nextInterval_2;
void setupChaser() {
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(8, OUTPUT);
pinMode(4, OUTPUT);
}
void loopChaser() {
digitalWrite(1, Primarystate);
digitalWrite(2, Secondarystate);
digitalWrite(4, Shuttlebaystate);
digitalWrite(8, Floodlightstate);
if (millis() >= waitUntillPrimary) {
Primarystate = true;
}
if (millis() >= waitUntillSecondary) {
Secondarystate = true;
}
if (millis() >= waitUntilShuttlebay) {
Shuttlebaystate = true;
}
if (millis() >= waitUntilFloodlight) {
Floodlightstate = true;
}
}
void setupFade() {
pinMode(impulsered, OUTPUT);
pinMode(impulseblue, OUTPUT);
pinMode(deflectororange, OUTPUT);
pinMode(deflectorblue, OUTPUT);
pinMode(nacellsviolet, OUTPUT);
pinMode(nacellsblue, OUTPUT);
}
void loopFade() {
analogWrite(impulsered, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255) {
fadeAmount = -fadeAmount ;
}
analogWrite(impulseblue, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255){
fadeAmount = -fadeAmount ;
}
analogWrite(nacellsviolet, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255){
fadeAmount = -fadeAmount ;
}
analogWrite(nacellsblue, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255){
fadeAmount = -fadeAmount ;
}
analogWrite(deflectororange, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255){
fadeAmount = -fadeAmount ;
}
analogWrite(deflectorblue, brightness);
brightness = brightness + fadeAmount;
if (brightness == 0 || brightness == 255){
fadeAmount = -fadeAmount ;
}
delay(10);
delay(10);
delay(10);
delay(10);
delay(10);
delay(10);
}
void setupBlink()
{
pinMode(strobe, OUTPUT);
nextInterval_1 = 2000;
pinMode(navigation, OUTPUT);
nextInterval_2 = 2000;
} // end of setup
void loopBlink() {
unsigned long currentMillis_1 = millis();
if (currentMillis_1 - previousMillis_1 > nextInterval_1)
{
previousMillis_1 = currentMillis_1;
if (strobeState == LOW)
{
strobeState = HIGH;
nextInterval_1 = 100;
}
else
{
strobeState = LOW;
nextInterval_1 = 8000;
}
digitalWrite(strobe, strobeState);
} // end if time up
{
unsigned long currentMillis_2 = millis();
if (currentMillis_2 - previousMillis_2 > nextInterval_2)
{
previousMillis_2 = currentMillis_2;
if (navigationState == LOW)
{
navigationState = HIGH;
nextInterval_2 = 100;
}
else
{
navigationState = LOW;
nextInterval_2 = 2000;
}
digitalWrite(navigation, navigationState);
}
}
}
Of course, I'm very interested in nicks code that he posted. Although its very far beyond me until I can play with it and see how to do things with it.
so theres that, and i will also be trying to change the 6 lines of delay to henry's delay idea.
To be perfectly honest, the pin changes should have been made from the very beginning and should NOT have been screwing around with code until i had those settings locked in and finalised. So im sorry about that. I know now, and it wont happen again in the future.
I also spent an hour last night cleaning up my breadboard and getting the leds on it in the right colors and groupings.
I'll post a new video later with the sequence working correctly.
OH!!!! can anyone tell me the load resistance, controller voltage and max current per pin please? I will need to know this for the hardware side of things.