Go Down

Topic: small helppppppp!!!!!!! required (Read 185 times) previous topic - next topic

anshchawla

Mar 05, 2019, 05:02 pm Last Edit: Mar 05, 2019, 07:42 pm by anshchawla
i have reached to the conclusion that the whole problem is based on the incorrect format of the varible
but cannot change variables format


i have attached a photo
when i try to print an element of array it prints something useless
but when i try to print the orignal value (results.value)
it works fine



pls helpppppppp!!!!!!!!!!!




code

:::::::::




 int t =0;
 int a=0;
 int b=0;
 byte gone[50];
 #include <IRremote.h>
 int RECV_PIN = 10;
 int i = 0;
 int m = 0;

 
void setup() {

pinMode(11 ,OUTPUT);
pinMode(10 ,INPUT);
pinMode(13 ,OUTPUT);
pinMode(12 ,OUTPUT);
pinMode(3 ,INPUT);
pinMode(2 ,INPUT);
Serial.begin(9600);

}

void loop() {
    a = digitalRead(2);
    b = digitalRead(3);
   
  if( a == HIGH || ( i != 0 && i != 51 )){
    IRsend irsend;
     Serial.println("transmit");
     Serial.println(i);
     irsend.sendNEC(gone[ i ], 11);
     Serial.println(gone[ i ]);
     Serial.println(" ");
     
   delay(40);
 i ++;
  }else{i = 0;
  }
    if( b == HIGH ){
     
      digitalWrite(12,HIGH);
      IRrecv irrecv(RECV_PIN);
      irrecv.enableIRIn();
      decode_results results;
      delay(100);
     if (irrecv.decode(&results)) {
      Serial.println("recieved");

 gone[m] = (results.value , HEX); 
    Serial.println(gone[m]);
     Serial.println(c);
    Serial.println(results.value, HEX);
    digitalWrite(13,HIGH);
    delay(500);
    digitalWrite(13,LOW);
    irrecv.resume();
    m ++;
  }

  }
 

}


6v6gt

#1
Mar 06, 2019, 05:20 am Last Edit: Mar 06, 2019, 05:20 am by 6v6gt
This looks rather odd:
gone[m] = (results.value , HEX ) ;
I'm sure it is not doing what it looks like you expect it to.
results.value appears also to be too big to fit into a single byte.

anshchawla


Go Up