Author Options:

How do i keep the LED on the whole time with logic 1 and turn off only when sending logic 0 between arduino and RF 315? Answered

Good evening sir. I am a college student taking electronics enginneering. i would like to ask for help if you don't mind regarding the use of arduino to control the on and off states of LED. I was hoping you can help me with my programming since the LED lights seem to be blinking only upon receiving logic 1. How do you keep it on the whole time with logic 1 and off only when it receives logic 0? Thanks!



2 years ago

It would be helpful to know what the purpose is, as well as some additional requirements, constraints, and goals in mind, as well as your technical background (e.g. are you new to arduino, to programming, to electronics, or all of it?)

I'm going to assume that this is for simply learning how to use arduino to do simple things such as digitalRead() and digitalWrite(). If that's the case, I recommend watching this series of videos from Jeremy Blum:

There are many possible ways to go about doing this. If you do not care about speed, timing or accuracy, than simply setting a 2 pins as an INPUT and OUTPUT respectively and constantly reading the INPUT pin and writing it's value to an output. Copy/paste the below line of code as a very basic example. As the code stands, it probably fast enough for most applications.

void setup(){

pinMode(9, INPUT);

pinMode(13, OUTPUT);


void loop(){

digitalWrite(13, digitalRead(9));


However, as you add more stuff to the loop, especially delays, big floating point math stuff, and slow serial Tx commands, the code will get slower, and you may find yourself needing to use interrupt-driven or event-driven code instead. If you determined once you add additional code into the loop that the sampling rate is not high enough, you may need to use some of the hardware interrupts. The same guy who made the video above has made videos about using the interrupt, some gotcha's involved with using them, etc. Using the interrupt will be a much better solution where timing is very important. but has some major disadvantages which may make it unsuitable for what you need.

Thanks sir. Yes im new to arduino and our project uses rf 315 tx rx. If the input coming from arduino to transmitter is 1, it will allow the phase of the receiver part for the led to turn on. It is a one way communication via rf 315. Basically it is like switching lights on and off only it relies on the input part of the arduino to transmitter.

If this is all you want to do, I would not even bother using the microcontroller and control the LED with a single transistor amplifier! Just connect the output pin of your RF module directly to a common emitter NPN transistor, with a 4.7K resistor between the base and RF output pin, with a 1K resistor between the collector and power, the emitter directly to ground, and the LED across the transistor's collector and emitter (or ground, same node) paying attention to polarity.

Sir, thank you for that but I have questions on the connections. My transmitter is connected to my power outage detector. The input for the transmitter relies on the output of the power outage detector then sends signal whether to light the LED. if there is power outage it sends signal to the receiver to turn on the LEDs. We also use bluetooth to control certain LED/s to turn on or off. But first, I am still working on the switching part of the LEDS wirelessly. How do I make the communication between the transmitter and receiver of RF315 using transistor to turn on/off LEDs relying on the power outage detector output? According to your reply, what do you mean about the RF module. Is it both the transmitter and receiver have the same pin configuration to the transistor?

The wiring for this sounds like it should be very simple. What is your level of education in electronics? Do you know theory, have you done much practice with basic circuits? are do you instead come from a computer-science and/or programming background like most people I meet? Knowing this will help me help you. Also pictures are worth a thousand words. Post some block diagrams, and and stuff you want to make.

A good place to start with parts that you do now know much about is the datasheet. For parts, they generally supply a simple/expected/common usage guides/schematics.

I'm on my second to the last semester before graduation hopefully sir. Yes, I know some basic theory but not so much practice with circuitry and know a little of programming. So here's a picture of my simple block diagram sir, I also included the flow chart :) Thanks so much!


Its very simple u need to take the input on and use a if else condition to show

led status.

I'll be trying this.thanks!

Failsafe would suggest using a latching relay if you're having problems maintaining a steady source programmatically.

You also have to be able to deliver enough power for the led you are attempting to energize. In cases where the expected load is greater than the arduino's logic pin can source/sink, use an appropriate intermediary buffer to deliver the required current.

I'd also recommend not using a self blinking led.

Thanks so much , ill take note of that:)