I messed up pretty bad on this, I have no idea how to do this. I'm assuming I should redo this with unsigned char, but I don't know how to do that. My goal is just a prototype code for a controller i'm working on for my current robot project. It should be able to detect 3 joysticks and there general direction. I'm really confused with how to send the IR codes. I had tried putting the signals and encoding them through a text to hex converter, but I got the error message
"Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Nano, ATmega328P (Old Bootloader)
unable to find numeric literal operator 'operator""a6f79737469636b317572'"
I would be grateful for any help, thank you!
Also I know there are still really bad errors in the code besides that, i'll fix that later tonight.
Also the blob of hex at the beginning was so I could copy and paste them later, the system works like a rose compass with ur being up right etc and o being a placeholder.
#include <IRremote.h>{
#define IR_SEND_PIN 5 //key for REWORK: first number = joystick, second number = u/d/o; (1,2,3), third number = l/r/o; (1,2,3)
#define ANALOG_X_PIN1 A2 //6e65757472616c7831 (neutralx1)
#define ANALOG_Y_PIN1 A3 //6e65757472616c7931 (neutraly1)
#define ANALOG_X_PIN2 A2 //6e65757472616c7832 (neutralx2)
#define ANALOG_Y_PIN2 A3 //6e65757472616c7932 (neutraly2)
#define ANALOG_X_PIN3 A2 //6e65757472616c7833 (neutralx3)
#define ANALOG_Y_PIN3 A3 //6e65757472616c7933 (neutraly3)
//Default values when axis not actioned 22+- is the point where it is considered an action; 150/106
#define ANALOG_X_CORRECTION1 128 //1 uo 6a6f79737469636b31756f ur 6a6f79737469636b317572 or 6a6f79737469636b316f72 dr 6a6f79737469636b3164721 REWORK: 1uo (113), 1ur (112), 1or (132), 1dr (122)
#define ANALOG_Y_CORRECTION1 128 //1 do 6a6f79737469636b31646f dl 6a6f79737469636b31646c ol 6a6f79737469636b316f6c ul 6a6f79737469636b31756c REWORK: 1do, 1dl, 1ol, 1ul
#define ANALOG_X_CORRECTION2 128 //2 uo 6a6f79737469636b32756f ur 6a6f79737469636b327572 or 6a6f79737469636b326f72 dr 6a6f79737469636b326472 REWORK: 2uo, 2ur, 2or, 2dr
#define ANALOG_Y_CORRECTION2 128 //2 do 6a6f79737469636b32646f dl 6a6f79737469636b32646c ol 6a6f79737469636b326f6c ul 6a6f79737469636b32756c REWORK: 2do, 2dl, 2ol, 2ul
#define ANALOG_X_CORRECTION3 128 //3 uo 6a6f79737469636b33756f ur 6a6f79737469636b337572 or 6a6f79737469636b326f72 dr 6a6f79737469636b336472 REWORK: 3uo, 3ur, 3or, 3dr
#define ANALOG_Y_CORRECTION3 128 //3 do 6a6f79737469636b33646f dl 6a6f79737469636b33646c ol 6a6f79737469636b336f6c ul 6a6f79737469636b33756c REWORK: 3do, 3dl, 3ol, 3ul
struct analogdata {
short x1, y1, x2, y2, x3, y3;
};
IRsend irsend;
void setup()
{
IrSender.begin();
}
void loop() {
analogdata analogdata;
analogdata.x1 = analogRead(ANALOG_X_PIN1) - ANALOG_X_CORRECTION1; //calculation for if the joystick is away from the origin
analogdata.y1 = analogRead(ANALOG_Y_PIN1) - ANALOG_Y_CORRECTION1;
if ((analogdata.x1 > 150) && (analogdata.y1 > 150)) { //upright/ur command
irsend.sendSAMSUNG(112);
}
else if ((analogdata.x1 > 150) && (analogdata.y1 < 106)) { //downright/dr command
irsend.sendSAMSUNG(122);
}
else if ((analogdata.x1 > 150) && (analogdata.y1 > 106) && (analogdata.y1 < 150)) { //right/or command
irsend.sendSAMSUNG(132);
}
else if ((analogdata.x1 < 106) && (analogdata.y1 > 150)) { //upleft/ul command
irsend.sendSAMSUNG(1);
}
else if ((analogdata.x1 < 106) && (analogdata.y1 < 106)) { //downleft/dl command
irsend.sendSAMSUNG(1);
}
else if ((analogdata.x1 < 106) && (analogdata.y1 > 106) && (analogdata.y1 < 150)) { //left/ol command
irsend.sendSAMSUNG(1);
}
}
(current code is above)