Print Hexadecimal Values In Arduino - Tutorialspoint
Maybe your like
- Home
- Whiteboard
- Online Compilers
- Practice
- Articles
- AI Assistant
- Jobs
- Tools
- Corporate Training
- Courses
- Certifications
- Switch theme
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
In order to print hexadecimal equivalents of numbers or characters, adding 'HEX' as the second argument of Serial.print() will be sufficient.
The following code demonstrates this −
Example
void setup() { // put your setup code here, to run once: Serial.begin(9600); Serial.println(); Serial.println(75); Serial.println(75, HEX); Serial.println('A'); Serial.println('A',HEX); } void loop() { // put your main code here, to run repeatedly: }The corresponding Serial monitor output is −

Now, the conversion of the decimal number 75 to a hexadecimal value is straightforward and you can even verify that 0x4B is the correct hexadecimal representation of 75. But what does the hexadecimal representation of 'A' mean?
Well, it is the hexadecimal representation of the number corresponding to A in the ASCII system.
As you can see, 'A' corresponds to number 65, whose hex representation would be 41.
Please note that hex representations do not work for floating point numbers. Serial.println(1.912,HEX); will only print 1.912.
Yash Sanghvi Updated on: 2021-03-23T11:21:41+05:30 9K+ Views
Tag » Arduino Convert Decimal A Hexadecimal
-
How Do I Convert Decimal To Hexadecimal? - Arduino Forum
-
Decimal To Hexadecimal - Store In A String - Arduino Forum
-
Converting Decimal To Hex - Programming Questions - Arduino Forum
-
Convert Integer/decimal To Hex On An Arduino? - Stack Overflow
-
Arduino Dec To Hex Code Example - Code Grepper
-
Convert Integer/decimal To Hex On An Arduino? - Tech Notes Help
-
Converting Decimal To HEX Values In Arduino
-
Arduino-Hex-Decimal-Conversion/hex_o At Master - GitHub
-
Convertir Entier/nombre Décimal En Hexadécimal Sur Un Arduino?
-
Convert Hex To Decimal From Signed 2's Complement
-
Resolved: Arduino - How To Convert Double To HEX Format
-
How To Write Arduino Code To Convert An 8-bit Binary To A Decimal ...
-
Creating A Number System Converter Create A Program