Help needed for cockpit display

Good morning,

Can anyone please help me with a little project I’m trying to solve.

I am new to any form of programming and haven’t touched electronics since leaving school 15 years ago and have pretty much forgot everything that i was taught!

I am currently restoring a Warbird cockpit and would like to get the instrument panel indication lights working with there relevent switches, i was pointed in the way or running it through an Arduino but not sure where to start!

The current switches and lights i would like to work are the a 3 way toggle switch that controls a light for bomb bay doors open light and a bomb bay door closed light, 4 lights for the landing Gear control lever.

The bomb bay doors i would like a 5 second delay before the lights turn on.

The landing gear is slightly more complicated, there is one green light, one amber light and 2 red lights.
The green light needs to be on when the lever in in the down position and the yellow night need to be on in the intermediate or up position but only for 12 second when in the up position and the red lights need to come on when the gear lever is in the intermediate or up position but only when the throttle is in the idle position, yup its complicated.

i will need to add some form of position switch in for the landing control lever and throttle as these were removed long before we got the cockpit.

i would also like to add other things on in the future i.e, more lights and some sound when the engine start switch is selected.

If anyone can help that would be fantastic.

Regards

Aaron

Start by simply following the tutorials for using LEDs. Don't try to write a lot of code at once, just start very simple and as you get one part working add others.

Look at Robin2's "Demonstration code for several things at the same time" sticky thread at the top of this forum. It'll get you started down the path of avoiding use of delay in your code which will become more important as you add functionality.

Do you have a picture of the cockpit?

Thanks for the advice.

i have read Robin2's demo and still getting confused, i know know about causing a delay without fusing delay and can get that to work with one led and switch, the problem i am now having is when i put another switch and led into the mix!

this is the code i currently have

unsigned long elapsedTime;
unsigned long offTime;
int bombbayopen = 12;
int bombopenswitch = 8;
int bombbayclosed = 11;
int bombclosedswitch = 7;

void setup()
{
 offTime = millis();
 offTime = elapsedTime; 
 pinMode(bombbayopen, OUTPUT);  
 pinMode(bombopenswitch, INPUT);    
 pinMode(bombbayclosed, OUTPUT);
 pinMode(bombclosedswitch, INPUT);
}

void loop()
{
 if (digitalRead(bombopenswitch) == LOW)  
        {
         digitalWrite(bombbayopen, LOW);    
         offTime = millis();
        }
         if(offTime > 0 && millis() - offTime > 8000)
         {
           digitalWrite(bombbayopen, HIGH);
           offTime = 0;
         }

if (digitalRead(bombclosedswitch) == LOW)  
        {
         digitalWrite(bombbayclosed, LOW);    
         offTime = millis();  
         }
     if(offTime > 0 && millis() - offTime > 8000)
           {      
           digitalWrite(bombbayclosed, HIGH);  
            offTime = 0;
           }  

}

The cockpit is an A26 invader pictures can be seen https://www.facebook.com/WingsA26/

Thanks again

Aaron

You really need to have a separate variable to keep track of time for the two operations. Sharing offtime between open and close is probably causing your problems.

thanks for the reply wildbill.

stupid question but how would i do that?

its probably been ask a 1000 time but i am really struggling here.

Thanks again

Aaron

like this:

unsigned long elapsedTime;
unsigned long OpenStartTime;
unsigned long CloseStartTime;
int bombbayopen = 12;
int bombopenswitch = 8;
int bombbayclosed = 11;
int bombclosedswitch = 7;

void setup()
{
  pinMode(bombbayopen, OUTPUT);
  pinMode(bombopenswitch, INPUT);
  pinMode(bombbayclosed, OUTPUT);
  pinMode(bombclosedswitch, INPUT);
}

void loop()
{
  if (digitalRead(bombopenswitch) == LOW)
  {
    digitalWrite(bombbayopen, LOW);
    OpenStartTime = millis();
  }
  if (OpenStartTime > 0 && millis() - OpenStartTime > 8000)
  {
    digitalWrite(bombbayopen, HIGH);
    OpenStartTime = 0;
  }

  if (digitalRead(bombclosedswitch) == LOW)
  {
    digitalWrite(bombbayclosed, LOW);
    CloseStartTime = millis();
  }
  if (CloseStartTime > 0 && millis() - CloseStartTime > 8000)
  {
    digitalWrite(bombbayclosed, HIGH);
    CloseStartTime = 0;
  }

}

Compiled, not tested.

WOW!!! THANK YOU!

Works perfectly! i need to do a lot more reading!

once again thank you!!