Quantcast
Channel: MSP430 Technical Forums
Viewing all articles
Browse latest Browse all 2077

How do I access sprintf() string values?

$
0
0
int incomingByte = 0; // for incoming serial data
char str1[4];
 
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
 
void loop() {
     if (Serial.available() >= 1) {
         incomingByte = Serial.read();
         sprintf(str1, "%02X ", incomingByte);     
         Serial.print(str1);
         
     }
}

 

It outputs:

7E 00 18 92 00 13 A2 00 40 A9 05 69 FF FE C1 01 00 00 0F 03 FF 03 FF 03 FF 03 FF 8B

 

My question is, how do I access/save the first byte, 7E, into a variable? and the second, and so on...

 

I've tried almost everything, and ive been going in circles for hours and hours


Viewing all articles
Browse latest Browse all 2077

Trending Articles