Results 1 to 7 of 7
  1. #1
    75+ Posting Member
    Join Date
    Feb 2010
    Location
    London
    Posts
    87
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    EFIS panel ans small help that I need with my sketch (how to turn off a LED) :)

    Hi there
    for some time now had been working on my radio stack and EFIS panel.
    It is inspired by the creator of link2FS ,and radio stack is simpy his idea.
    some parts of the sketch are from google and others came from my V1 vesion.

    At the moment it looks like this
    IMAG0332.jpg

    At the momet I have a problem witch the buttons on the right upper side.
    They have LED inside them.

    So basicaly when I press the btton the LED should turn on When I press it again it should turn off.
    And I have that part ,and it works great
    Here is the sketch for that loop

    void LED() { //Loop for the LEDs on te buttons
    //-------------ILS LED
    button1 = digitalRead(26);
    if(button1 != buttonold1)
    {
    if (button1 == HIGH) {Push1 = Push1 +1;
    delay(20);
    }
    }
    buttonold1 = button1;
    if (Push1 == 2 && button1 == HIGH ) {Push1 = 0;} //reset to zero if Push == 2
    if (Push1 == 0 && button1 == HIGH) { digitalWrite (65,HIGH);}
    if (Push1 == 1 && button1 == HIGH) { digitalWrite (65,LOW);}
    //--------FD LED
    button2 = digitalRead(2;
    if(button2 != buttonold2)
    {
    if (button2 == HIGH) {Push2 = Push2 +1;
    delay(20);
    }
    }
    buttonold2 = button2;
    if (Push2 == 2 && button2 == HIGH ) {Push2 = 0;} //reset to zero if Push == 2
    if (Push2 == 0 && button2 == HIGH) { digitalWrite (66,HIGH);}
    if (Push2 == 1 && button2 == HIGH) { digitalWrite (66,LOW);}


    //------first button from the left
    button3 = digitalRead(3;
    if(button3 != buttonold3)
    {
    if (button3 == HIGH) {Push3 = Push3 +1;
    delay(20);
    }
    }
    buttonold3 = button3;
    if (Push3 == 2 && button3 == HIGH ) {Push3 = 0;} //reset to zero if Push == 2
    if (Push3 == 0 && button3 == HIGH) { digitalWrite (64,HIGH);}
    if (Push3 == 1 && button3 == HIGH) { digitalWrite (64,LOW);}

    //-------------Second butto fro the left
    button4 = digitalRead(36);
    if(button4 != buttonold4)
    {
    if (button4 == HIGH) {Push4 = Push4 +1;
    delay(20);
    }
    }
    buttonold4 = button4;
    if (Push4 == 2 && button4 == HIGH ) {Push4 = 0;} //reset to zero if Push == 2
    if (Push4 == 0 && button4 == HIGH) { digitalWrite (63,HIGH);}
    if (Push4 == 1 && button4 == HIGH) { digitalWrite (63,LOW);}

    //--------------Thisrd butto from the left
    button5 = digitalRead(34);
    if(button5 != buttonold5)
    {
    if (button5 == HIGH) {Push5 = Push5 +1;
    delay(20);
    }
    }
    buttonold5 = button5;
    if (Push5 == 2 && button5 == HIGH ) {Push5 = 0;} //reset to zero if Push == 2
    if (Push5 == 0 && button5 == HIGH) { digitalWrite (62,HIGH);}
    if (Push5 == 1 && button5 == HIGH) { digitalWrite (62,LOW);}

    //--------------Fourth button fromthe left
    button6 = digitalRead(32);
    if(button6 != buttonold6)
    {
    if (button6 == HIGH) {Push6 = Push6 +1;
    delay(20);
    }
    }
    buttonold6 = button6;
    if (Push6 == 2 && button6 == HIGH ) {Push6 = 0;} //reset to zero if Push == 2
    if (Push6 == 0 && button6 == HIGH) { digitalWrite (61,HIGH);}
    if (Push6 == 1 && button6 == HIGH) { digitalWrite (61,LOW);}

    //--------------Fifth button from the left
    button7 = digitalRead(30);
    if(button7 != buttonold7)
    {
    if (button7 == HIGH) {Push7 = Push7 +1;
    delay(20);
    }
    }
    buttonold7 = button7;
    if (Push7 == 2 && button7 == HIGH ) {Push7 = 0;} //reset to zero if Push == 2
    if (Push7 == 0 && button7 == HIGH) { digitalWrite (60,HIGH);}
    if (Push7 == 1 && button7 == HIGH) { digitalWrite (60,LOW);}

    }

    Right what I want next.
    I press the button,LED from that button comes on,and then I press another button,I want the LED from previous button to come off and the LED from the button I just did press to come on,and so on.

    ay idea how to modify or what I need to add

  2. #2
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: EFIS panel ans small help that I need with my sketch (how to turn off a LED) :)

    You could store the lastbutton, to sort out witch last led was turned HIGH.

    if ie. button 60 is HIGH, digitalWrite the led in the last button LOW.
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  3. #3
    500+ This must be a daytime job



    Join Date
    Jan 2009
    Location
    Tampa
    Posts
    531
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: EFIS panel ans small help that I need with my sketch (how to turn off a LED) :)

    I was sort of thinking along those lines: if button 60 == HIGH, digitalWrite ALL others low

  4. #4
    75+ Posting Member
    Join Date
    Feb 2010
    Location
    London
    Posts
    87
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: EFIS panel ans small help that I need with my sketch (how to turn off a LED) :)

    Ok thoe ideas are great but I think teris a point missed
    So button 1 or 2 or ect has a digital read to the pin that the button is connected to
    Now this is lnked to Push1 or 2 or ect with is the counter that counts how many times te button is beeing pushed .
    So 1 click Push ==1 and LED is on ,second click push == 2 LED off .
    That is correct and has to stay as it is.
    Works great and has to be this way

    Now the whole idea is how to turn off LED when pressing other button.

    I was thinkig of using "or" instead of "and"

    So somthing like
    if (Push5 == 1 && button5 == HIGH || button1 == HIGH || button2 == HIGH) { digitalWrite (62,LOW);}

    But that doe not work



    If I had a sketch witch 2 LED and 2buttons I might do somthing out of it

  5. #5
    150+ Forum Groupie BuzziBi's Avatar
    Join Date
    Mar 2013
    Location
    Norway
    Posts
    275
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: EFIS panel ans small help that I need with my sketch (how to turn off a LED) :)

    Just thinking loud her. Have not tryed, but somehow it should be possible to:

    if (Push6 == 0 && button6 == HIGH) { digitalWrite (60,62,63,64,65, LOW); digitalWrite(61,HIGH);}
    Life was hard, but then came Windows 7.
    Now we can fly! --------
    --------

  6. #6
    75+ Posting Member
    Join Date
    Feb 2010
    Location
    London
    Posts
    87
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: EFIS panel ans small help that I need with my sketch (how to turn off a LED) :)

    What about usinh "or" instead of "and"
    does anyone know how to inplement that

  7. #7
    75+ Posting Member
    Join Date
    Feb 2010
    Location
    London
    Posts
    87
    Contribute If you enjoy reading the
    content here, click the below
    image to support MyCockpit site.
    Click Here To Contribute To Our Site

    Re: EFIS panel ans small help that I need with my sketch (how to turn off a LED) :)

    Hi there
    by te way ,any idea whre in UK I can get 20x4 LCD with letters on black bckfround for sensible price.