LEDs IF/ELSE

Good morning, first of all sry for my bad english! I need some help here, trying to find some tutorial but nothing usefull for me, everybody can BLINK a LED with encoders or buttons but thats not what i need, and i´m kind a noob with this to figure it out by my self!
What i need… i need to get one led to blink when other led is go up!!
Something like this:

If LED “parking break” - OFF —> LED “my new led” - OFF
If LED “parking break” - ON ----> LED “my new led” - BLINK

Hope i was clear, thanks!

[arduino mega2560, common LEDs 5mm (10-15 leds), power supply DC 5v 2A, no shields, maybe will use 16ch multiplexor]

the base code is silas parker´s code for ETS2 arduino dashboard project:

#include <Servo.h>

const int SPEEDO_PIN      = A0;
const int RPM_PIN         = A1;
const int FUEL_PIN        = A5;
const int LEFT_INDICATOR  = A2;
const int RIGHT_INDICATOR = A3;
const int PARKING_BREAK   = A4;
const int FUEL_WARNING    = 12;


// defines servo names
Servo speedo;
Servo rpm;
Servo fuel;
Servo cruise;

#define PACKET_SYNC 0xFF
#define PACKET_VER  2

#define SERVO_DIR_NORMAL false
#define SERVO_DIR_INVERT true
#define BAUD (9600)
int serial_byte;

void setup()
{
  Serial.begin(115200);
 
  speedo.attach(SPEEDO_PIN);
  speedo.write(180);
  rpm.attach(RPM_PIN);
  rpm.write(180);
  fuel.attach(FUEL_PIN);
  fuel.write(40);
  cruise.write(180);
 
  pinMode(LEFT_INDICATOR, OUTPUT);
  pinMode(RIGHT_INDICATOR, OUTPUT);
  pinMode(PARKING_BREAK, OUTPUT);
  pinMode(FUEL_WARNING, OUTPUT);


  //range-splitter LED's
  pinMode(22, OUTPUT);
  pinMode(24, OUTPUT);
  pinMode(26, OUTPUT);
 
  digitalWrite(LEFT_INDICATOR, 0);
  digitalWrite(RIGHT_INDICATOR, 0);
  digitalWrite(PARKING_BREAK, 0);
  digitalWrite(FUEL_WARNING, 0);
 
 
  delay(600);
 
  speedo.write(0);
  rpm.write(0);
  fuel.write(0);
  digitalWrite(LEFT_INDICATOR, 1);
  digitalWrite(RIGHT_INDICATOR, 1);
  digitalWrite(PARKING_BREAK, 1);
  digitalWrite(FUEL_WARNING, 1);

  digitalWrite(22, 1);
  digitalWrite(24, 1);
  digitalWrite(26, 1);
 
  delay(600);
 
  speedo.write(180);
  rpm.write(180);
  fuel.write(85);
  digitalWrite(LEFT_INDICATOR, 0);
  digitalWrite(RIGHT_INDICATOR, 0);
  digitalWrite(PARKING_BREAK, 0);
  digitalWrite(FUEL_WARNING, 0);
  digitalWrite(22, 0);
  digitalWrite(24, 0);
  digitalWrite(26, 0);

  delay(1000);
}

void read_serial_byte_set_servo(Servo& servo, bool invert)
{
  serial_byte = Serial.read();
  serial_byte = (serial_byte < 0) ? 0 : ((serial_byte > 180) ? 180 : serial_byte);
  if (invert)
    servo.write(180 - serial_byte);
  else
    servo.write(serial_byte);
}

void read_serial_byte_set_servo_fuel(Servo& servo, bool invert)
{
  serial_byte = Serial.read();
  serial_byte = (serial_byte < 0) ? 0 : ((serial_byte > 180) ? 180 : serial_byte);
  if (invert)
    servo.write(85 - serial_byte); //set lower than the tach and speedo to limit movement.
  else
    servo.write(serial_byte);
}


void skip_serial_byte()
{
  (void)Serial.read();
}

void digitalWriteFromBit(int port, int value, int shift)
{
  digitalWrite(port, (value >> shift) & 0x01);
}

void loop()
{
  if (Serial.available() < 16)
    return;
 
  serial_byte = Serial.read();
  if (serial_byte != PACKET_SYNC)
    return;
   
  serial_byte = Serial.read();
  if (serial_byte != PACKET_VER)
  {
//    lcd.clear();
 //   lcd.print("PROTOCOL VERSION ERROR");
    return;
  }
 
  read_serial_byte_set_servo(speedo, SERVO_DIR_INVERT); // Speed 
  read_serial_byte_set_servo(rpm, SERVO_DIR_INVERT); // RPM
 
  skip_serial_byte(); // Brake air pressure
  skip_serial_byte(); // Brake temperature
  read_serial_byte_set_servo_fuel(fuel, SERVO_DIR_INVERT); // Fuel ratio
  skip_serial_byte(); // Oil pressure
  skip_serial_byte(); // Oil temperature
  skip_serial_byte(); // Water temperature
  skip_serial_byte(); // Battery voltage 

  if (cruise.read() < 180)
  {

      }
  if (cruise.read() > 179)
      {
      }
 
  // Truck lights byte
  serial_byte = Serial.read();
  digitalWriteFromBit(LEFT_INDICATOR,  serial_byte, 5); 
  digitalWriteFromBit(RIGHT_INDICATOR, serial_byte, 4);

 
 // Warning lights bytes

  serial_byte = Serial.read(); 
  digitalWriteFromBit(PARKING_BREAK, serial_byte, 7);
  digitalWriteFromBit(FUEL_WARNING, serial_byte, 3); 
 
  // Enabled flags
  serial_byte = Serial.read();
 
  // Text length
  int text_len = Serial.read();
 
// Followed by text
  if (0 < text_len && text_len < 127)
  {
    for (int i = 0; i < text_len; ++i)
    {
     
      while (Serial.available() == 0) // Wait for data if slow
      {
        delay(2);
      }
    }
  }
}

Step one:
as you mentioned

everybody can BLINK a LED

have YOU checked the example "Blink Without Delay" and have you understood, what it is doing?
Is EACH LINE of the example "Blink Without Delay" clear for you?
Does it work on your Hardware?

If you you can give me 3 x YES, we can proceed.

noiasca:
Step one:
as you mentioned
have YOU checked the example "Blink Without Delay" and have you understood, what it is doing?
Is EACH LINE of the example "Blink Without Delay" clear for you?
Does it work on your Hardware?

If you you can give me 3 x YES, we can proceed.

i wrote... everybody can blink a led WITH ENCODER OR BUTTON.... but cant find any "if A led ON - - -> blink led B"

in the same way, as you can read the state of a button, you also can read the state of your OUTPUT pin.

After you have activated your parking break with something like

digitalWrite(PARKING_BREAK, ON);

you can easily check later in your sketch if the parking break is on

if (digitalRead(PARKING_BREAK))
{
  do_blinkWithoutDelay();
}

so you now have each component you need.

  • You told everybody knows how to blink - this includes you.
  • You know how to check the state of your parking break.

looks pretty good! I´ll try it now, tnx!!

{
  if(digitalRead(BATERIA) == HIGH){
    digitalWrite(ENGINE_CHK, HIGH)
  }
  else{
    digitalWrite(ENGINE_CHK, LOW);
  }

this was the code i wrote... but didnt worked (verify code was succesfully btw). i was pretty close i think hehe but where is the error? like i told i´m new in coding this stuffs :-[

You need to post all your code. Your mistake is in the bits you didn’t post.