using hex-code

hey there right now i’m orking on a new IRMP-Projekt.
So far I’m able to receive and decode the Ir-signal of several remotes.

now i want to use the decoded hex-code to turn a digital pin high and low.
can you please tell me how that works. for exmple if i push red button hex code E0E036C9 is displayed.
By pushing red button i want o switch pin 13 from low to high and oherway round

what d i need to add to my programm?

Unbenannt.jpg

bonsai878: if i push red button hex code E0E036C9 is displayed. By pushing red button i want o switch pin 13 from low to high and oherway round

  if (results->value == 0xE0E036C9)
      digitalWrite(13, !digitalRead(13));

but this does not make the Output Switch between high and low. this makes the Output Switch one time and it holds on. so there is not resetfunktion.

  digitalWrite (13, ! digitalRead (13)) ;

Will invert the output on pin 13 whatever its current state, if it is currently an OUTPUT pin and not externally shorted to Vcc or GND.

bonsai878: but this does not make the Output Switch between high and low. this makes the Output Switch one time and it holds on. so there is not resetfunktion.

It should. Show your code. Perhaps there is an error somewhere.

include "IRremote.h"

int receiver = 11; int Relais1 = 13;

IRrecv irrecv(receiver); // create instance of 'irrecv' decode_results results; // create instance of 'decode_results'

void setup() { Serial.begin(9600); irrecv.enableIRIn(); // Start the receiver

}

void loop() { if (irrecv.decode(&results))

{ translateIR(); irrecv.resume(); } }

void translateIR()

{

switch(results.value)

{

case 0xE0E036C9: Serial.println("rot"); break; digitalWrite (13, ! digitalRead (13)) ;

case 0xE0E028D7: Serial.println("gruen"); break;

case 0xE0E0A857: Serial.println("gelb"); break;

case 0xE0E06897: Serial.println("blau"); break;

case 0xE0E0926D: Serial.println("record/aus"); break;

default: Serial.println("other button "); Serial.print(results.value, HEX); } delay(500); }

You have no pinMode() command in setup() for the relay pin so it is defaulting to being an input.

You forgot pinMode(Relais1, OUTPUT); in setup().

#include "IRremote.h"

const int receiver = 11;
const int Relais1  = 13;

IRrecv irrecv(receiver);           // create instance of 'irrecv'
decode_results results;            // create instance of 'decode_results'

void setup() 
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
  pinMode(Relais1, OUTPUT);
}

void loop()   
{
  if (irrecv.decode(&results)) 
  {
    translateIR(); 
    irrecv.resume(); 
  }  
}

void translateIR()
{
  switch(results.value)
  {
  case 0xE0E036C9:  
    Serial.println("rot"); 
    break;
    digitalWrite (13, ! digitalRead (13)) ;

  case 0xE0E028D7:  
    Serial.println("gruen"); 
    break;

  case 0xE0E0A857:  
    Serial.println("gelb"); 
    break;

  case 0xE0E06897:  
    Serial.println("blau"); 
    break;

  case 0xE0E0926D:  
    Serial.println("record/aus"); 
    break;

  default: 
    Serial.println("other button   ");
    Serial.print(results.value, HEX);
  }
  delay(500);
}

finaly got it... =) break; needs to stand after digitalwrite =)

void translateIR() { switch(results.value) { case 0xE0E036C9: Serial.println("rot"); digitalWrite (13, ! digitalRead (13)) ; break;

break; needs to stand after digitalwrite =)

AND the pinMode() issue reported by the two previous posts.


Rob