So I don't know C so I'm just trying to get some very very basic code running on my arduino to send it commands over serial.
I'm feeding serial into buf
irsend.sendNEC(0x210704FB, 32)
this works but I need to read from buf instead of hardcoding for one code.
irsend.sendNEC(buf, 32) won't compile but irsend.sendNEC((uint32_t) buf, 32) will. It just doesn't do anything.
When I use
serial.print((uint32_t) buf, 32);
it prints just seemingly random letters?
I'm trying to just feed it a serial code with a language I know a little better. I can send the hex code over serial with python but I don't know the first thing about C. I don't understand why I can't just feed it a variable and have it read it as is. here's my code
#include <IRremote.h>
char buf[80];
int readline(int readch, char *buffer, int len) {
static int pos = 0;
int rpos;
if (readch > 0) {
switch (readch) {
case '\r': // Ignore CR
break;
case '\n': // Return on new-line
rpos = pos;
pos = 0; // Reset position index ready for next time
return rpos;
default:
if (pos < len-1) {
buffer[pos++] = readch;
buffer[pos] = 0;
}
}
}
return 0;
}
void setup() {
Serial.begin(115200);
}
IRsend irsend;
void loop() {
if (readline(Serial.read(), buf, 80) > 0) {
//tried to set up code to show what the arduino received and tried ways to send
//Serial.print("You entered: >");
//Serial.print(buf);
//Serial.println("<");
//doesn't seem to do anything irsend.sendNEC((uint32_t) buf, 32);
//works but only for this one button irsend.sendNEC(0x210704FB, 32);
//want to use irsend.sendNEC(buf, 32);
//me trying to figure out what irsend is being fed through buf Serial.print((uint32_t) buf, 32);
}
}
buf? The first twosendNECin your question are identical but you say one compiles and one doesn't - probably a wrong copy/paste. Please edit your question to clarify.serial.print(...., 32). "32" is not a valid second parameter for theserial.print()function when printing an integer value. Just leave it out or replace it with either "BIN", "DEC", "OCT" or "HEX". BTW, what is your question exactly?