hey guys I just wanted to make this publicly available since I couldn’t find anyone else who has made this before.
This is a HEX to long(or string to hex) converter that takes strings as an input. I’m making a program that writes colors to a screen after reading them from an SD card so I needed this. figured someone else in the future may as well.
The screen uses hex in its display library rather then RGB so I was stuck with either converting string to hex to RGB or just string to hex and dealing with using some online converter to make my colors. I actually had no idea what hex was until after I did this so this taught me a lot about base 16 and what it is actually useful for. Feel free to use this code however you want. If you need to just steal the ConvertHex(); function feel free to and pop a string into it and it will return a value of type long!
feel free to remove all of the lines including serial commands they are just for demo use.
here is how you can test it out!
first get the code from below and upload it to an arduino of choice.
set your baud rate to 9600 and type in “HEX FFFF”
this should return the value 65535. which is represent of FFFF in hex.
as seen here
My main purpose in making this post is just so google shows some relevant results when googling “arduino hex to int converter” like the noob I am.