Ich versuche gerade, einen Rechner zu machen, und dies ist der erste Teil der Gleichung, wo der Benutzer eine Nummer mit einer IR-Fernbedienung eingeben wird.Arduino Ausgabeprobleme
Momentan ist mein Problem, wenn ich die Zahlen, die ich in das Array eingegeben habe, als Strings ausgeben (damit ich sie später kombinieren kann), gibt es ungerade Zeichen aus. so weit
Dies ist mein Code:
#include <boarddefs.h>
#include <IRremote.h>
#include <IRremoteInt.h>
#include <ir_Lego_PF_BitStreamEncoder.h>
int RECV_PIN = 6;
IRrecv irrecv(RECV_PIN);
decode_results results;
int part1digits = 0;
String part1[16];
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (part1digits <= 15) {
while (!irrecv.decode(&results)) {
/* DO NOTHING WHEN NO IR SIGNAL IS RECEIVED
This WHILE loop will run continuously, doing nothing
until there IS a signal received
*/
}
// if IR signals is received, then do this
getCode();
part1digits++;
} else {
for (int i = 0; i <= 15; i++) {
Serial.print(part1[part1digits]);
}
// The while loop below is to 'stop' the program
while(1){}
}
}
void getCode() {
if (results.value == 16738455) {
part1[part1digits] = "0";
Serial.println(part1[part1digits]);
}
else if (results.value == 16724175) {
part1[part1digits] = "1";
Serial.println(part1[part1digits]);
}
else if (results.value == 16718055) {
part1[part1digits] = "2";
Serial.println(part1[part1digits]);
}
else if (results.value == 16743045) {
part1[part1digits] = "3";
Serial.println(part1[part1digits]);
}
else if (results.value == 16716015) {
part1[part1digits] = "4";
Serial.println(part1[part1digits]);
}
else if (results.value == 16726215) {
part1[part1digits] = "5";
Serial.println(part1[part1digits]);
}
else if (results.value == 16734885) {
part1[part1digits] = "6";
Serial.println(part1[part1digits]);
}
else if (results.value == 16728765) {
part1[part1digits] = "7";
Serial.println(part1[part1digits]);
}
else if (results.value == 16730805) {
part1[part1digits] = "8";
Serial.println(part1[part1digits]);
}
else if (results.value == 16732845) {
part1[part1digits] = "9";
Serial.println(part1[part1digits]);
}
// Serial.println(results.value, HEX);
delay(250); // Delay, so you don't send 3 signals back to back
// while the button is depressed.
irrecv.resume(); // Receive the next value
}
Ein kleiner Ausschnitt aus Ausgang ich immer bin, nachdem ich in alle meine Werte eingegeben haben, sind:
ôïÿ9ÝKÏÞóõx;ÿoקÿ^Øè«ÙÝ™ë]^ �ßå¿n'Þ