Hello,
I'm looking to control a small battery powered device, which uses a 315 mhz remote control with 3 buttons. I was able to use a receiver (purchased here: 315Mhz Wireless RF Transmitter Module + Receiver Alarm Arduino DIY USA | eBay), and the rc_switch library (using recieveDemo_advanced) to receive some codes/commands from the remote, like the one posted below:
Decimal: 26010 (16Bit) Binary: 0110010110011010 Tri-State: not applicable PulseLength: 503 microseconds Protocol: 2
Raw data: 5132,528,860,852,548,808,588,96,1280,108,1280,808,596,56,1324,764,640,748,648,40,1340,712,696,692,2072,700,660,28,1352,736,2056,24,1328,
I'm trying to send the codes I collected back to the device, to control it in the same way as the controller, but so far haven't had any luck. Is the 315 mhz transmitter I bought capable of 'speaking' to the device in the same way its controller does? The transmitting code I've been using is below:
/*
Example for different sending methods
https://github.com/sui77/rc-switch/
*/
#include <RCSwitch.h>
int input;
RCSwitch mySwitch = RCSwitch();
void setup() {
Serial.begin(9600);
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
// Optional set protocol (default is 1, will work for most outlets)
mySwitch.setProtocol(2);
// Optional set pulse length.
mySwitch.setPulseLength(500);
// Optional set number of transmission repetitions.
// mySwitch.setRepeatTransmit(15);
}
void loop() {
if (Serial.available() > 0) {
input = Serial.read();
Serial.println(input);
}
else {
input = -1;
}
switch (input) {
case '-1':
// do nothing
break;
case '1':
// power button
mySwitch.send("0110010110011010");
Serial.println("power button");
break;
case '2':
// top once
mySwitch.send("1011010101001010");
Serial.println("top once");
break;
case '3':
// top hold
mySwitch.send("1011111001000001");
Serial.println("top hold");
break;
case '4':
// bottom once
mySwitch.send("1011101001000101");
Serial.println("bottom once");
break;
case '5':
// bottom hold
mySwitch.send("0111100110000110");
Serial.println("bottom hold");
break;
default:
//Serial.println("unknown entry");
break;
}
}
Thanks