If you’re into microcontrollers you know the ability to think and perform math in binary is a must. [Joe Ptiz] has been looking for a way to keep from being distract by the math when coding while still keeping the binary strings in the forefront of his mind. The solution he came up with is to use the Python interpreter as a binary math aide.

We knew that you could use Python to convert between decimal, hexadecimal, and binary. But we failed to make the leap to using it for troubleshooting bit-wise operations. We can see this being especially useful when working with sixteen-bit I/O ports like those found on STM32 chips. For us it’s easy to do 8-bit math in our head, but doubling that is another story.

The image above is one screenshot from [Joe's] tutorial. This illustrates a few different bit-wise operators given decimal inputs but displaying binary as output. He also illustrates how you can use python to test out equations from C code by first setting the variables, pasting the equation, then printing the result to see if the output is what was expected.

## Recent comments