Prazados, boa tarde!!
Gostaria da ajuda de vocês pois estou com um projeto para ativar as lampadas de casa por RF433 com Interruptores Livolo. No entanto estou com diversas dúvidas no código, pois não sou programador. Pesquisando consegui identificar o remoteID e código de acesso para cada botão (lâmpada) do controle.
Ai está a minha dúvida... Onde e de que forma inserir todos os outros IDs dos interruptores no código?
sendButton(1897, 0); // - Sala
sendButton(1897, 96); // - Varanda
sendButton(1897, 120); // - Hall de entrada
#define txPin 8 // pin connected to RF transmitter (pin 8)
byte i; // just a counter
byte pulse; // counter for command repeat
boolean high = true; // pulse "sign"
void setup() {
}
void loop() {
sendButton(6400, 120); // blink button #3 every 3 seconds using remote with remoteID #6400
delay(3000);
}
void sendButton(unsigned int remoteID, byte keycode) {
for (pulse= 0; pulse <= 180; pulse = pulse+1) { // how many times to transmit a command
sendPulse(1); // Start
high = true; // first pulse is always high
for (i = 16; i>0; i--) { // transmit remoteID
byte txPulse=bitRead(remoteID, i-1); // read bits from remote ID
selectPulse(txPulse);
}
for (i = 7; i>0; i--) { // transmit keycode
byte txPulse=bitRead(keycode, i-1); // read bits from keycode
selectPulse(txPulse);
}
}
digitalWrite(txPin, LOW);
}
void selectPulse(byte inBit) {
switch (inBit) {
case 0:
for (byte ii=1; ii<3; ii++) {
if (high == true) { // if current pulse should be high, send High Zero
sendPulse(2);
} else { // else send Low Zero
sendPulse(4);
}
high=!high; // invert next pulse
}
break;
case 1: // if current pulse should be high, send High One
if (high == true) {
sendPulse(3);
} else { // else send Low One
sendPulse(5);
}
high=!high; // invert next pulse
break;
}
}
void sendPulse(byte txPulse) {
switch(txPulse) { // transmit pulse
case 1: // Start
digitalWrite(txPin, HIGH);
delayMicroseconds(500); // 550
digitalWrite(txPin, LOW);
break;
case 2: // "High Zero"
digitalWrite(txPin, LOW);
delayMicroseconds(100); // 110
digitalWrite(txPin, HIGH);
break;
case 3: // "High One"
digitalWrite(txPin, LOW);
delayMicroseconds(300); // 303
digitalWrite(txPin, HIGH);
break;
case 4: // "Low Zero"
digitalWrite(txPin, HIGH);
delayMicroseconds(100); // 110
digitalWrite(txPin, LOW);
break;
case 5: // "Low One"
digitalWrite(txPin, HIGH);
delayMicroseconds(300); // 290
digitalWrite(txPin, LOW);
break;
}
}
Agradeço a Ajuda.