SoftwareSerial Ausgabe in HEX

Hallo,

Ich bin zimlich neu was Arduino betrifft und habe mit folgenden Code ein Problem.
Der Code ist auch nicht von mir.

Noch zur Erklärung was ich machen möchte.

Ich sende mit der Fernbedienung vom Samsung TV per IR ein Code (zb. Taste 1) und es soll mit SoftwareSerial am Arduino und einem MAX232 ein anderer HEX Code gesendet werden.

So wie es jetzt ist gibt der Arduino die (Translate) in ASCII aus und nicht in HEX.
Kurz gesagt im Abschnitt (Translate to RS232) möchte ich den Wert unter lastCommand diese Werte als HEX an die RS232 übetragen. Im Moment wird es als ASCII behandelt und dann umgewandelt in HEX.
Leider ist mir es nicht gelungen.
Wäre nett wenn mir jemand helfen könnte wie ich es ändern könnte

Gruß

Stephan

#include <IRremote.h>
#include <IRremoteInt.h>
#include <SoftwareSerial.h>



//------------------------------------------------------------------------------
// Tell IRremote which Arduino pin is connected to the IR Receiver (TSOP4838)
//
int recvPin = 6;
IRrecv irrecv(recvPin);
/*
  / int blinkPin = 4;
  / IRrecv irrecv(recvPin, blinkPin); */
SoftwareSerial mySerial(10, 11); // RX, TX



//------------------------------------------------------------------------------
// We use this string for repeat commands
String lastCommand = String("");

//+=============================================================================
// Configure the Arduino
//
void  setup ( )
{
  mySerial.begin(9600); // RS232 output
  irrecv.enableIRIn();  // Start the receiver
  irrecv.blink13(true);

}

//+=============================================================================



// Translate to RS232
//
void  translate (decode_results *results)
{
  switch ((results->value)) {

    case 0xE0E020DF:      lastCommand = "ADA103010001A6";     mySerial.print(lastCommand);      delay(100);     break ; // Power On

    case 0xE0E0A05F:      lastCommand = "ADA103000001A5";     mySerial.println(lastCommand);      delay(100);     break ; // Power Off

    case 0xE0E0609F:      lastCommand = "ADA20114B7";     mySerial.println(lastCommand);      delay(100);     break ; // move right

    case 0xE0E010EF:      lastCommand = "ADA20113B6";     mySerial.println(lastCommand);      delay(100);     break ; // move left

    case 0xE0E0906F:      lastCommand = "ADA20112B5";     mySerial.println(lastCommand);      delay(100);     break ; // move down

    case 0xE0E050AF:      lastCommand = "ADA20111B4";     mySerial.println(lastCommand);      delay(100);     break ; // move up

    case 0xE0E030CF:      lastCommand = "ADA50101A7";     mySerial.println(lastCommand);      delay(100);     break ; // red

    case 0xE0E0B04F:      lastCommand = "ADA50102A8";     mySerial.println(lastCommand);      delay(100);     break ; // green

    case 0xE0E0708F:      lastCommand = "ADA50103A9";     mySerial.println(lastCommand);      delay(100);     break ; // yellow

      // case 0xFFFFFFFF: mySerial.println(lastCommand); delay(45); break;
  }
}


//+==========================================================================
// The repeating section of the code
//

void  loop ( )
{
  decode_results  results;        // Somewhere to store the results
  if (irrecv.decode(&results)) {  // Grab an IR code
    translate(&results);
    irrecv.resume();              // Prepare for the next value


  }
}

Sorry, aber so ist der Sketch kaum lesbar.

Bitte formatiere den in der IDE (Strg + T) und setze den hier in Code-tags (Schaltfläche </> oben links im Editor.

Und eine Beschreibung was dieser Sketch machen soll, fehlt auch.

Ein String kann nur als Text ausgegeben werden. Für HEX mußt Du einen Zahlenwert angeben, z.B. results->value. Aber selbst dann funktioniert die formatierte Ausgabe nur, wenn SoftSerial die auch eingebaut hat - bin mir da nicht sicher.