Hi, i've some problems using RCSwitch. I want to send 24 bit to program six buttons on a remote control. To do it the right way I need to create first 16 bit that represents the remote control address, and the next 8 bit are the data bit that the controller will send. The thing is that I have a 16 bit counter that increments, I'll need to add the other 8 bits to it to send it (I don't know how to do it yet, if you can help me with this too I'll thank you) and can only send it when I have declared it between "". I'm using an MX-FS-03V. For example:
I know it has to be something about characters, but can't find a way. Thanks for helping. Here is the complete code just in case.
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
int id = 0;
void setup() {
Serial.begin(9600);
// Transmitter is connected to Arduino Pin #10
mySwitch.enableTransmit(10);
mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2
// Optional set protocol (default is 1, will work for most outlets)
// mySwitch.setProtocol(2);
// Optional set pulse length.
mySwitch.setPulseLength(415);
// Optional set number of transmission repetitions.
// mySwitch.setRepeatTransmit(15);
Serial.println(id);
}
void loop() {
uint8_t bitsCount = sizeof( id ) * 8;
char str[ bitsCount + 1 ];
uint8_t i = 0;
while ( bitsCount-- )
str[ i++ ] = bitRead( id, bitsCount ) + '0';
str[ i ] = '\0';
}
char *add = "000000000000000000000000";
delay(200);
mySwitch.send(add);
}