Arduino data retention

in short, incoming data data = 5592332 . I want to keep this data temporarily and rewrite it to the serial monitor when the button is pressed. but long data= mySwitch.getReceivedValue(); I can't retrieve the data because the variable is inside the if

#include <RCSwitch.h>
int buton=8;

RCSwitch mySwitch = RCSwitch();

void setup() {
  Serial.begin(9600);
  mySwitch.enableReceive(0);
    
  
}

void loop() {

 if (mySwitch.available()) {
    long veri= mySwitch.getReceivedValue();
    Serial.println( mySwitch.getReceivedValue() );
    mySwitch.resetAvailable();
    delay(3000);
    

}
 if(buton==HIGH){
 Serial.println(veri);

 }
}

In short, this is not and installation question…

I moved your post to a better place.

do yourself a favour and please read How to get the best out of this forum and modify your post accordingly.

—-

Read about variable scope and declare your variable at the right level. When you get new data set a flag and make sure there is nothing blocking the loop

https://www.w3schools.in/c-programming/variable-scope start here

Didn't I just answer this question, but where you talk about the EEPROM feature you aren't using?

int buton=8;
...
 if(buton==HIGH){
...

So, you are saying "if 8==HIGH" ???

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.