See Post#5 and Post#8
.
I'm testing a P10 LED panel with a 433Mhz remote control.
Every time the 433Mhz control button is pressed, 1 line of text will be written to a .TXT file in LittleFS. from nodemcu12E.
The problem is that when we keep the button pressed, a burst (pulses) comes out of the 433Mhz remote control.
If this signal is not handled, the .TXT file would have infinite lines in a short time.
So writing should only occur when we release the button after holding it down. I.e. we tighten and then release. It is on the descent from this 'edge' that writing must occur. This is the condition.
What I tried to do was: As soon as you press the button, an int called counter goes to condition 1 and thus ignores the other pulses from the remote control.
Later on, I said that if the recebesinal is equal to zero and the contador is equal to 1, that is, if the remote control button is released. It will start a timer (cron++) as if it were Millis(). When this cron reaches a close value, the signal int becomes equal to one. The board's internal LED turns on and off monitoring the process.
recebesinal = 1 means that printing occurred in the.txt file.
After printing the line I need to make the recebesinal = 0;
But this is the problem, if I do this, if I keep the button pressed I will see one more line being printed in the .txt file and so I will have infinite lines being printed again if I keep the button pressed.
The correct option is to just print 1 line as soon as you release the button. Squeeze and then release.
#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();
const int ledinterno = D4;
int recebesinal,cron,cron1,contador;
unsigned long codigorecebido;
void setup() {
Serial.begin(115200);
pinMode(ledinterno, OUTPUT);
mySwitch.enableReceive(D2); // Receiver on interrupt 0 => that is pin #2
}
void loop() {
if (mySwitch.available()) {
codigorecebido = mySwitch.getReceivedValue();
Serial.print( mySwitch.getReceivedValue() );
mySwitch.resetAvailable();
} else {
codigorecebido = 0;
}
if(codigorecebido == 167914277 && contador == 0) {
contador = 1;
}
if(codigorecebido == 0 && contador == 1) {
digitalWrite(ledinterno, LOW);
cron++;
Serial.println(cron);
if(cron > 500) {
digitalWrite(ledinterno, HIGH);
cron = 0;
contador = 0;
recebesinal = 1;
Serial.println(recebesinal);
}
}
}
Does anyone know how to do it ?
Thanks