From the course: Raspberry Pi: GPIO

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Binary and bitwise math

Binary and bitwise math

From the course: Raspberry Pi: GPIO

Start my 1-month free trial

Binary and bitwise math

- [Instructor] In each of the examples in this chapter, I've used something called bitwise and to convert a number from decimal to binary and then use that value to turn on a light. My explanation in each video was brief for a reason. Logic statements like and don't have anything to do with controlling the GPIO. Bitwise and is a common math operation but not a GPIO operation. So I'm including this video as an explanation of that piece of code. If you already understand bitwise and operations, you should skip ahead to the next chapter. Before I explain bitwise and, let's take a look at where it was used. For example, the Python RPi.GPIO code. Open up 08_03_python_rpi_gpio, and look at lines 40 through 43. You can see an ampersand right in the middle of the line. That's the symbol for a bitwise and in the Python programming language. And is an operator like addition, division, multiplication, or others. It takes one or…

Contents