Need a bit of guidance. Controlling car electrics using relays.

Evening all,

I will first start by saying this is my first project with an arduino and in fact any electronics project at all. But you don't get anywhere by not throwing yourself in at the deep end (Although my project Is fairly simple mind)

So hardware layout.

[u]Physical switches[/u] existing switches around the steering column, all will have a GND signal running through them. (Simulating using tactile switches)

I have this section of the code working using simple if statements.

  if (digitalRead(Mainin) == LOW){digitalWrite(Main, LOW); }
  if (digitalRead(Mainin) == HIGH){digitalWrite(Main, HIGH);}

Arduino Mega and HC05 Bluetooth module.

[u]Android tablet for non physical switches[/u]

I also have this working.

if (Dipped_state == 0 && Received == 'b')
  {
    digitalWrite(Dipped,HIGH);
    Dipped_state=1;
    Received=0;  
  }
if (Dipped_state == 1 && Received == 'b')
  {
    digitalWrite(Dipped,LOW);
    Dipped_state=0;
    Received=0;
  }

However. I cannot for the life of me get the hazards to flash using the tablet interface. I am at a loss of direction to head towards. I have managed to get the indicators (turn signal in the us) to work using.

  if (digitalRead(Lindicatein) == LOW){digitalWrite(Lindicate, LOW);delay(500);digitalWrite(Lindicate, HIGH); delay(500); }
  if (digitalRead(Lindicatein) == HIGH){digitalWrite(Lindicate, HIGH);}

I do wish to make a move away from using a delay within the code to achieve this.

So does anyone mind poking me in the right direction?

Thanks

Sam

Most vehicles have a seperate flasher relay to run the indicators/hazards. You just have to energise that.

To avoid usinhg delay() - a good idea - look at the BlinkWithoutDelay example in the IDE

Allan.

Hi Alan,

Cheers for the input. The plan was to use the arduino to control the signal rather then using the flasher unit.

The idea is to centralise all of the electrics and just run single wires to each component.

Ive had a quick look at the blink without delay code. However how would be best to implement it?

Create another variable within my indicator and hazard blocks and then use that variable to control the code for "blink without delay" using if statements once more.

Or would it be better to switch to using case statements?