I am new to arduino. I have a project in which I need an arduino to generate a +5VDC signal in response to a change of status, (high/5VDC To low/ground) from an external source.
The external source is a stand alone receiver/transmitter set which outputs +5VDC when the transmitter is out of range and ground when the transmitter is within range.
The goal is to have the arduino output +5VDC (triggering a series of events) only when the TX is within range of the RX (signal voltage is GRND vs. +5vDC). The series of events are controlled via a stand alone event controller which is initiated by a +5VDC signal courtesy of the arduino.
I already have a RX/TX set which outputs +5VDC when the the TX is absent and GROUND when the TX is within range. I also have the event controller. I only need the arduino solution.
I have an arduino UNO but I am open to other option if needed.
Solution: give me +5VDC when signal voltage (from receiver) is low (ground).
If anyone could point me in the right direction it would be greatly appreciated. This is my first arduino project so I have much to learn.
Best regards
2 Answers 2
This is literally the simplest Arduino program possible. I can't believe you couldn't find an example of making one pin HIGH when another goes LOW.
void setup(){
pinMode(yourInputPin, INPUT_PULLUP);
pinMode(yourOutputPin, OUTPUT);
}
void loop(){
if(digitalRead(yourInputPin) == LOW){
digitalWrite(youOutputPin, HIGH);
}
else {
digitalWrite(yourOutputPin, LOW);
}
}
All you need to do is supply the appropriate pin numbers.
Why waste an Arduino on such a paltry job? Here's a circuit that has just 3 components in it that does what you want:
schematic
simulate this circuit – Schematic created using CircuitLab
It's basically a NOT gate (you can use an actual NOT gate, like a 74HC04 if you like) where the output is the opposite of the input. You could even remove R2 if you like - that just prevents the input floating when there's no valid signal detected.
This form of gate is called RTL - Resistor-Transistor Logic, and is one of the simplest logic gate arrangements there is.