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.
Python and RPi.GPIO control of GPIO
- [Instructor] RPi.GPIO is a code library that allows Python to communicate with the GPIO. It's been around since January of 2012 and is widely used and supported. In fact, GPIO zero is based on RPi.GPIO. So let's take a look at how to implement code to control our binary counter circuit. In lines four through 13 is basic set up, we import some libraries and create a few variables. Note line 11, RPi.GPIO doesn't have an LED board construct like GPIO zero. Instead, LEDs can be stored as a Python tuple. RPi.GPIO can handle interrupts and the functions defined in lines 16 through 27 handle these interrupts. The first, on line 16, handled reset, loops while the button returns zero. The button we have set up, returns zero if it's pressed and one if it's released. The not in line 17 inverts the zero, so that the button value reflects the intended logic. While the button is pressed, line 18 sets all of the LEDs to high,…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Introduction to programming the Raspberry Pi GPIO3m 37s
-
(Locked)
Python and GPIO Zero control of GPIO5m 23s
-
(Locked)
Python and RPi.GPIO control of GPIO4m 51s
-
(Locked)
Scratch control of GPIO8m 2s
-
(Locked)
Bash control of GPIO8m 35s
-
(Locked)
Node-RED control of GPIO8m 13s
-
(Locked)
C control of GPIO6m 28s
-
(Locked)
Java control of GPIO8m 7s
-
(Locked)
Wolfram control of GPIO3m 59s
-
(Locked)
Binary and bitwise math8m 34s
-
(Locked)
-
-