hi every body im new to arduino & read serial.print section and know using of standard form of it but these are little different:
Serial.print(sector < 10 ? " " : " “); // Pad with spaces
Serial.print(blockAddr < 10 ? " " : (blockAddr < 100 ? " " : " “)); // Pad with spaces
“If the number is only one digit (<10), output two spaces. Otherwise output one space.”
See “ternary operator”
b?c:d; can be read as “if b, use the value c, otherwise use the value d”
really thanks for your kindly help
please let me interpret the code line by line based on your guide
if sector is <10 then send 3 space via usart , else send 2 space via usart .
send sector via usart.
send 2 space via usart.
is it true? or first line only do perpare format of data for sending (like sprintf function in cpp)
yeah, you can use something like that to print the leading zero if for example you are printing time in a digital clock…
if (hour < 10)
so it outputs:
time = 09
time = 10