Hello everybody
I use ask-433 mhz receiver and rc-switch library. when I use "mySwitch.enableReceive(0)" it works fine in pin D2 but when I change it to "mySwitch.enableReceive(13)" it don't work in pin D13!!!! please help
In the Arduino IDE, use Ctrl T or CMD T to format your code then copy the complete sketch.
Use the </> icon from the ‘reply menu’ to attach the copied sketch.
Which board? Pin 13 is usually the builtin led and the implementation varies between different manufacturers. The pin is also used for SPI (but I doubt a little that is your problem).
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
mySwitch.enableReceive(4); // Receiver on interrupt 0 => that is pin #2
pinMode(A5, OUTPUT);
}
void loop() {
if (mySwitch.available()) {
digitalWrite(A5, HIGH);
output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(), mySwitch.getReceivedProtocol());
mySwitch.resetAvailable();
delay(500);
digitalWrite(A5, LOW);
}
}
also I check pin 3, 4, 5, 8
I use arduino UNO
What about using PINMODE for your Switch-Pin first during setup?
https://www.arduino.cc/reference/en/language/functions/digital-io/pinmode/
RCSwitch uses interrupts. On a Uno only pins 2 and 3 have interrupt ability and they are addressed as 0 (pin2) and 1 (pin3). So try connecting to pin3 and using 'mySwitch.enableReceive(1);' As the comment in the code clearly says enableReceive() takes an interrupt number NOT a pin number.
Steve
thanks. my problem solved with your help
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.