Hi,
My arduino is recieving some data from a wiimote over TWI. I have the arduino capture about 190 bytes, then the arduino transmits those back to my PC over a serial connection. Currently I am storing the data in an uint8_t array and transmitting them over serial with Serial.print (storebuf~~,DEC). That works fine and minicom reads the data fine. ~~
What I would like to do is store the data in a character array. That way I could put in some spaces are commas between the data. Right now I don’t know where one set of receiveevents starts/stops. So I wanted to insert a comma. The problem is when I store the data in a char array and send it back to my pc with Serial.print (storebuf~~), I get strange characters instead of the numbers. So it looks like my numbers from Wire.recieve don’t like to be translated into characters.
Any thoughts on how I can store this as character data and have it transmit back over serial in a readable format?
thanks
chad
Here is part of my code:
uint8_t storebuf[200];
int cnt = 0;
void
receiveEvent (int howMany)
{
while (Wire.available ())
{
int c = Wire.receive (); // receive byte as a character~~
~~ storebuf[cnt] = c;
cnt++;
if (cnt > 100)
{
print ();
}
}
}
void
print ()
{
int s = 0;
Serial.println (“start data dump”);
while (s < (cnt - 1))
{
Serial.print (storebuf,DEC);
s++;
}
Serial.println (“end data dump”);
cnt = 0;
}
Here is what I tried, but sent back bad characters. Only the comma would print correctly:
char storebuf[200];
int cnt = 0;
void
receiveEvent (int howMany)
{
while (Wire.available ())
{
char c = Wire.receive (); // receive byte as a character~~
~~ storebuf[cnt] = c;
cnt++;
if (cnt > 100)
{
print ();
}
}
storebuf[cnt] = ‘,’; // Add in a comma~~
~~ cnt++;
}
void
print ()
{
int s = 0;
Serial.println (“start data dump”);
while (s < (cnt - 1))
{
Serial.print (storebuf);
s++;
}
Serial.println (“end data dump”);
cnt = 0;
}~~