void setup() {
Serial.begin(9600);
unsigned short int myVariable = 12345;
// Decimal format
Serial.print("Decimal format: ");
Serial.println(myVariable);
// Hexadecimal format
Serial.print("Hexadecimal format: 0x");
Serial.println(myVariable, HEX);
// Binary format
Serial.print("Binary format: ");
for (int i = 15; i >= 0; i--) {
Serial.print(bitRead(myVariable, i));
}
Serial.println();
// ASCII representation (if applicable)
if (myVariable >= 32 && myVariable <= 126) {
Serial.print("ASCII representation: ");
Serial.println((char)myVariable);
}
}
void loop() {
// Your main code goes here
}