Boa noite,

Recentemente tive um problema com meu Arduino MEGA, do qual estava rodando minha automação com um pouco de engasgos... Acabei trocando o mesmo por um Arduino DUE, do qual tive que trocar algumas libraries além de fazer a adaptação de 5v para 3.3v

Porém estou tendo um problema com o módulo de RF, o mesmo no Arduino MEGA rodava o seguinte código e conseguia ligar/desligar meu interruptor da livolo.

#define txPin 8 // pin connected to RF transmitter (pin 8)
byte iii; // just a counter
byte pulse; // counter for command repeat
boolean high = true; // pulse "sign"

void setup()
{

}

void loop()
{

sendButton(19303, 106); // (LUZ) Comando "OFF"

delay(5000);

}


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;
}
}

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 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 (iii = 16; iii > 0; iii--) { // transmit remoteID
byte txPulse = bitRead(remoteID, iii - 1); // read bits from remote ID
selectPulse(txPulse);
}

for (iii = 7; iii > 0; iii--) { // transmit keycode
byte txPulse = bitRead(keycode, iii - 1); // read bits from keycode
selectPulse(txPulse);
}
}
digitalWrite(txPin, LOW);
}

Porém agora com a migração pro DUE, acredito que os intervalos entre os bits mudaram, não tenho certeza se seria isso...

Como faço para identificar os novos delays de microsegundos que o arduino DUE usa, seria apenas com um osciloscópio?

Caso seja algo que não seja viável para um iniciante como eu, gostaria de saber se alguem conhece uma biblioteca específica para Arduino DUE, dai com ela consigo colocar um receptor, enviar o sinal de um mega, copiar ele e depois transmitir com o DUE.

Obrigado, Heitor.

Exibições: 239

Responder esta

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço