I am very new to this area of coding and I need desperate help. We are trying to code the 433 Mhz transmitter and receiver so they can talk to each other. One of the sensor will move, transmitter or receiver, and once that sensor exceeds a range, the LED will turn off. The LED is on the receiver and it will turn off the minute the transmitter exceeds the range. We tried a variety of examples from online but there is always complications. Can anyone help me with this project?
This is the code we are using so far.
/*
RF Blink - Receiver sketch
Written by ScottC 17 Jun 2014
Arduino IDE version 1.0.5
Website: http://arduinobasics.blogspot.com
Receiver: XY-MK-5V
Description: A simple sketch used to test RF transmission/receiver.
------------------------------------------------------------- */
#define rfReceivePin A0 //RF Receiver pin = Analog pin 0
#define ledPin 8 //Onboard LED = digital pin 13
#define ledPin2 9
unsigned int data = 0; // variable used to store received data
const unsigned int upperThreshold = 70; //upper threshold value
const unsigned int lowerThreshold = 50; //lower threshold value
void setup(){
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop(){
data=analogRead(rfReceivePin); //listen for data on Analog pin 0
if(data>upperThreshold){
digitalWrite(ledPin, HIGH); //If a LOW signal is received, turn LED OFF
Serial.println(data);
digitalWrite(ledPin2, HIGH);
delay(100);
}
if(data<lowerThreshold){
digitalWrite(ledPin, LOW); //If a HIGH signal is received, turn LED ON
Serial.println(data);
digitalWrite(ledPin2, LOW);
delay(100);
}
}
/*
RF Blink - Transmit sketch
Written by ScottC 17 Jun 2014
Arduino IDE version 1.0.5
Website: http://arduinobasics.blogspot.com
Transmitter: FS1000A/XY-FST
Description: A simple sketch used to test RF transmission.
------------------------------------------------------------- */
#define rfTransmitPin 4 //RF Transmitter pin = digital pin 4
//Onboard LED = digital pin 13
void setup(){
pinMode(rfTransmitPin, OUTPUT);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop(){
for(int i=4000; i>5; i=i-(i/3)){
digitalWrite(rfTransmitPin, HIGH); //Transmit a HIGH signal
digitalWrite(LED_BUILTIN, HIGH); //Turn the LED on
delay(2000); //Wait for 1 second
digitalWrite(rfTransmitPin,LOW); //Transmit a LOW signal
digitalWrite(LED_BUILTIN, LOW); //Turn the LED off
delay(i); //Variable delay
}
}