Hello,
I am having a problem of when I do a serial.print(data[4],DEC) from a char/byte array I get strange values. So sometimes instead of getting a "255" I get a "-1"
I have tried using unsigned int instead of int but instead of getting "-1" I get numbers like 65525.
replacing serial.print(packetdata[ i],DEC) with serial.print(packetdata[ i],HEX) also give bad values like "FFFFFFDA" instead of something like "DA"
void Sendpacket(unsigned int toaddr,byte data[11] )
{
byte packetdata[16];
packetdata[0] = toaddr ;
for (i = 0; i < 11; i = i + 1) {
packetdata[5+i] = data[i];
}
for (i = 5; i < Mirf.payload; i = i + 1) {
unsigned int val = packetdata[i];
Serial.print(val); // this is to trye and fix the issue of 255 sometimes being displayed as -1, but now gets displayed as like 65501
// Serial.print(packetdata[i],DEC);
Serial.print(",");
}
void loop(){
byte message[11] = " ";
int BatteryVoltage = readVcc();
message[7] = (BatteryVoltage >> 8) & 0xFF, BYTE;
message[8] = BatteryVoltage & 0xFF, BYTE;
Sendpacket(255,message);
}
I am still using version 22 of Arduino due to some of the libraries I require not supporting version 1.0
Below is some of the code I use, I am using it with MIRF but the data is going screwy before it even gets to MIRF