I need help, how to 433mhz led control button, I don't know where there is a problem with my system, my experiment is to turn the button to press down and the led to turn on, and the button to turn to put-off the led to turn off. Now the experiment shows that the lights are all on
TR:
#include <RCSwitch.h>
int buttonPinA3 =2;
int buttonPinA4 =3;
int buttonPinA5 =4;
int buttonPinA6 =5;
int buttonState = 0;
RCSwitch mySwitch = RCSwitch();
void setup() {
pinMode(13, OUTPUT);
pinMode(buttonPinA3, INPUT_PULLUP);
pinMode(buttonPinA4 , INPUT_PULLUP);
pinMode(buttonPinA5 , INPUT_PULLUP);
pinMode(buttonPinA6 , INPUT_PULLUP);
mySwitch.enableTransmit(10);
}
void loop() {
buttonState = digitalRead(buttonPinA3 == buttonPinA4);
if (digitalRead(buttonPinA3) == HIGH) {
digitalWrite(13,HIGH);
mySwitch.send(10, 24);
} else if (digitalRead(buttonPinA4) ==HIGH) {
digitalWrite(13, HIGH);
mySwitch.send(10, 24);
} else if (digitalRead(buttonPinA5) == HIGH) {
digitalWrite(13, HIGH);
mySwitch.send(10, 24);
} else if (digitalRead(buttonPinA6) ==HIGH) {
digitalWrite(13, HIGH);
mySwitch.send(10, 24);
}
else {
mySwitch.send(20, 24);
digitalWrite(13, LOW);
}
}
RX:
#include <RCSwitch.h>
int ledpinQ1 = 3;
int ledpinQ2 = 4;
int ledpinQ3 = 5;
int ledpinQ4 = 6;
RCSwitch mySwitch = RCSwitch();
void setup() {
pinMode(ledpinQ1, OUTPUT);
pinMode(ledpinQ2, OUTPUT);
pinMode(ledpinQ3, OUTPUT);
pinMode(ledpinQ4, OUTPUT);
Serial.begin(9600);
mySwitch.enableReceive(0);
}
void loop() {
if (mySwitch.available()) {
int value = mySwitch.getReceivedValue();
if (value == 10) {
digitalWrite(ledpin, HIGH);
rial.println("1");
}
else {
digitalWrite(ledpin,LOW);
Serial.println( mySwitch.getReceivedValue() );
}
mySwitch.resetAvailable();
}
}