Radio Frequency Controlled LED
by thisisrammy in Circuits > Wireless
3699 Views, 36 Favorites, 0 Comments
Radio Frequency Controlled LED
Control the brightness of the LED with a RF module. Super easy project for all ages!
Requirements
An Arduino Uno
RF Module
A LED
Jump Wires
USB Data Cable
Connections and Codes
Connect the Vcc of the Transmitter (Small in size) and the Receiver (Big in size) to the +5 Volts on the arduino and connect the Negative terminals to the Ground of the Arduino. Notice that there are Data terminals on the Transmitter as well on the Receiver. The Data terminal on the Transmitter is where the Input signal must be given and the Data terminal on the Receiver board will give the Output. An LED is connected to the 13th pin to control the brightness based on the RF Signal value you feed in. Connect the transmitter Data to the Digital Pin 4 and connect the receiver Data to the Analog pin A0.
Your code should look similar to this -
#define rfTransmitPin 4
#define ledPinn 13
#define rfReceivePin A0
#define ledPin 13
unsigned int data = 0;
const unsigned int upperThreshold = 70;
const unsigned int lowerThreshold = 50;
void setup() {
pinMode(rfTransmitPin, OUTPUT);
pinMode(ledPinn, OUTPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
for (int i=4000; i>5; i=i-(i/3)) {
digitalWrite(rfTransmitPin, HIGH);
digitalWrite(ledPinn, HIGH);
digitalWrite(rfTransmitPin,LOW);
digitalWrite(ledPinn, LOW);
}
data=analogRead(rfReceivePin);
if (data>upperThreshold) {
digitalWrite(ledPin, LOW);
Serial.println(data);
}
if(data<lowerThreshold) {
digitalWrite(ledPin, HIGH);
Serial.println(data);
}
}
Power Up !
Upload the codes to the Board. When we give a high Input to the transmitter, the LED glows dim. When we give a low input to the transmitter, the LED glows with high intensity. We can view the received values in the Serial monitor of the Arduino.