I read in a tagline on here that the key to getting good answers lies in asking good questions, so I'll do my best to give all the relevant information. I'm looking for a way to communicate team and player information over infrared for a game for a camp I run.
I'm early enough in the project that I don't really have much preference for how this data is formatted, but I would like there to be some sort of order to it. I would eventually like to build this ir message by concatenating some variables because I don't want it to be static. In other words, if certain things happen, you might change from team 1 to team 2. That sort of thing.
Ok, so even though I don't have any preference for data type, I'm thinking shorter and simpler would be easier. I've been able to transmit my signal 200+ yards with only the arduino's 5v out, a 2n2222a, and a cheap lens. I'm super happy with that part. It's the data that I'm having issues with.
My original thought was that I would go with team being the first digit 1-9 (hex throws out leading 0's) and then a 3 digit player number. So 1001 would signify team 1, player 0001. 5132 would be team 5, player 132. I hope that makes sense.
So, I've made a sketch that shoots out 5 of these preformatted IR Blasts as such
irsend.sendSony(0x3E8, 12);//Team 1, Player 000 (1000)
delay(150);
irsend.sendSony(0x7CF, 12);//Team 1, Player 999 (1999)
delay(150);
irsend.sendSony(0x2328, 12);//Team 9, Player 000 (9000)
delay(150);
irsend.sendSony(0x270F, 12);//Team 9, Player 999 (9999)
delay(150);
irsend.sendSony(0x140C, 12);//Team 5, Player 132 (5132)
delay(150);
The de-defacto IR Receive Dump Sketch (basically this one)
Receives the first two fine.
irsend.sendSony(0x3E8, 12);
is received as 3E8 (1000)
irsend.sendSony(0x7CF, 12);
is received as 7CF (1999)
irsend.sendSony(0x2328, 12);
BUT is received as 328 (808)
irsend.sendSony(0x270F, 12);
AND is received as 70F (1807)
irsend.sendSony(0x140C, 12);
AND is received as 40C (1036)
I'm pretty sure this is due to the bit length. I was kind of hoping 12 would be enough to cover that 4 digit number but that's obviously not the case. Extending the bit length on those last 3 causes them to work and breaks the first 2.
So...finally...what I'm asking for is there any format where I can either have a fixed bit length or be able to calculate this bit length on the fly so I can have some semblance of order to my code. I feel like this has to be doable, I just don't know enough of the ins and outs of c and IR to format it properly. So far it has been trial and error.
Thanks for your time!