Raspberry Pi: An Advanced Guide to Setup, Expert Programming(Concepts, theories and techniques) and Build Raspberry Pi Projects by Grant Joe

Raspberry Pi: An Advanced Guide to Setup, Expert Programming(Concepts, theories and techniques) and Build Raspberry Pi Projects by Grant Joe

Author:Grant, Joe [Grant, Joe]
Language: eng
Format: epub, pdf
Published: 2020-08-14T16:00:00+00:00


Understanding the Script

First of all, the states for enabling and disabling LEDs are required to be defined according to the RGB LED type that is being used (common cathode). If the RGB LED is an ‘Anode’, the states for enabling / disabling have to be reversed.

Then the mapping of GPIO with the pins according to the wiring done is to be defined.

By combining the basic colors red, blue, and green color combinations are also defined.

In this Python script, there are several noteworthy functions. Let us start with the led_setup(). This function forwards the numbering of the GPIO pins that are to be used as outputs to the GPIO.BOARD. Lastly, we also use the led_clear() function that reset the state of the pins, i.e., reverting the pins to their default setting with them being disabled.

On the Gpio header, the led_gpiocontrol() function assigns pre-defined states to either a single GPIO pin or, if required, all of the GPIO pins. The isinstance() function is used to determine whether a value matches a specific type, i.e., am integer. After this, the state of a single pin can be defined, or the user can go through the entire list of pins and define the state for each pin individually.

Subsequently, in order to control the lighting up of the LEDs, the appropriate functions are needed to be defined in the script. These functions are the led_activate() and led_deactivate() respectively. Moreover, to control the time span in which an LED stays switched on is defined by the led_time() . Note that this function is also used for keeping a specific color of the LED lit up in a cycle. When the time allotted by this function expires, the LED turns off and lights up with a new color on the next cycle.

Lastly, the led_cleanup() function is used to revert the state and value of the pins to default. Moreover, this function calls upon the GPIO.cleanup() function to release the GPIO pins from use.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Architecting High-Performance Embedded Systems by Jim Ledin(1324)
DIY Microcontroller Projects for Hobbyists by Miguel Angel Garcia-Ruiz Pedro Cesar Santana Mancilla(1247)
Raspberry Pi For Dummies by Sean McManus(763)
Computers for Seniors for Dummies by Nancy C. Muir(621)
Troubleshooting and Maintaining PCs All-in-One For Dummies by Dan Gookin(566)
Windows 10: The Missing Manual by Pogue David(522)
Arduino Uno: A Hands-On Guide for Beginner by Agus Kurniawan(467)
Getting Started with Adafruit FLORA by Becky Stern(462)
Teach Yourself VISUALLY Chromebook by Guy Hart-Davis(434)
Samsung Galaxy S6 for Dummies by Bill Hughes(418)
IMac for Dummies by Chambers Mark L.;(373)
Raspberry Pi: A Step-by-Step Guide For Beginners to Program and Set-Up Top 10 Raspberry Pi Projects + First Steps on Configuration by Cage Jonathan(367)
Raspberry Pi 4: The Ultimate Step-by-Step Guide to Using Raspbian to Create Incredible Projects and Expand Your Programming Skills with the Latest Version of Raspberry Pi by Liam Clark(356)
2020 Ultimate Guide to Raspberry Pi : Tips, Tricks and Hacks by oney Youssef & oney Youssef(350)
iPad For Seniors For Dummies by Jesse Feiler(350)
Software Architecture by Neal Ford(345)
Super Arduino: Step-by-Step Instructions to Build Cool Gadgets by Kenneth Hawthorn(335)
Raspberry Pi: Tips and Tricks to Learn Raspberry Pi Programming by Pratt Logan(322)
Build Your Own Autonomous NERF Blaster by Bryce Bigger(312)
RASPBERRY PI 4 : A Comprehensive Guide to Raspberry Pi 4 Setup, Learning Programming and Developing Innovative Projects by DENTON DUKE(312)