Help With Input having a 5V output

HI everyone,

I'm very new to the arduino language and hardware, I'm trying to make what I think is a simple circuit but I can't figure it out.

What I'm trying to acomplish is activating a 5v relay module VMA406 from velleman with a signal input that originally is 12v, I went from 12v to a 5v regulator and all that seems to be working fine, then I send that 5v signal to my input (3) but the input is already reading HIGH before I even apply power to it. I tried having an in line 10k ohm pull down resistor on the input but it does't seem to make a difference. So in short my problem is that the input reads HIGH before I get my 12v signal.

Below is my code, this is probably version 20 so there is some things that don't make sense on it.

I really hope someone can help me with this.

Thanks in advance!

int SignalBrake =3; //Use Digital pin 3 to get signal from brake light
int SignalRunning =4; //Use Digital pin 4 to get signal running light
int Signaltorelaybrake =5; //Use Digital pin 5 to drive brake relay
int Signaltorelayrunninglight =6; //Use Digital pin 6 to drive running light relay
int SignalBrakeState = 0; //variable for storing Brake State
int SignalRunningState = 0;

void setup() {
Serial.begin (9600);

// initialize digital pin 3 and 4 as Input, 4 and 5 Output :
pinMode(SignalBrake, INPUT);
pinMode(SignalRunning, INPUT);
pinMode(Signaltorelaybrake, OUTPUT);
pinMode(Signaltorelayrunninglight, OUTPUT);
}

void loop() {

if (digitalRead(SignalBrake)== HIGH){
digitalWrite (Signaltorelaybrake, HIGH);
}

else {digitalWrite (Signaltorelaybrake, LOW);
}

if (digitalRead (SignalRunning) == HIGH){
digitalWrite (Signaltorelayrunninglight, HIGH);
}

else{ digitalWrite (Signaltorelayrunninglight, LOW);
}

SignalBrakeState = digitalRead(SignalBrake);
Serial.print ("SignalBrake Status");
delay (1000);
Serial.println (SignalBrakeState);
delay (1000);

SignalRunningState = digitalRead(SignalRunning);
Serial.print ("SignalRunning Status");
delay (1000);
Serial.println (SignalRunningState);
delay (1000);
}

A circuit diagram would be helpful.

Allan

Circuit diagram please. You need to make sure that all grounds are connected.

Regulators are for powering things not for changing signal levels, a simple 2 resistor voltage divider usually works better for that.

And pulldown resistors are not "in line" they go from the pin to ground. And they always work when connected correctly.

Just as a matter of principle you should really do the digitalReads into your "...State" variables at the top of loop and then use the "...State" variables in the comparisons and prints. It's not helpful to act on one read value and then read that pin again, possibly several seconds later, and print that second value.

Steve

Best approach is to first just wire the input , get it working then move on .
This way you can be sure where the problem lies before you develop a load of code and wonder where the problem lies.

Check the digital input with the simple example in the IDE.

You can go back to this step , and find your problem

Javyracer:
with a signal input that originally is 12v, I went from 12v to a 5v regulator and all that seems to be working fine

Without a circuit diagram it is hard to know exactly what that means.

The most usual way of adapting a 12v signal to the 5v limit of an Arduino is with a voltage divider made from a pair of resistors.

...R

I'm worried about the term 'inline' when used with 'pull-down resistor'. The resistor should connect between the input pin and ground. That should read LOW with nothing else attached.

Note that most relay modules are designed to be Active LOW. That means a LOW signal on the input turns the relay ON and a HIGH signal on the input turns the relay OFF.

 if (digitalRead (SignalRunning) == HIGH){
    digitalWrite (Signaltorelayrunninglight, HIGH);
  }

  else{ digitalWrite (Signaltorelayrunninglight, LOW);
  }

==

digitalWrite (Signaltorelayrunninglight, digitalRead (SignalRunning) );

Please remember to use code tags when posting code.