Adding in an LED
You'll already be familiar with how to control an LED from Chapter 7, Exploring the Raspberry Pi's GPIO Pins. In this instance, we will once again hook the LED up to the Raspberry Pi's GPIO pins. We will then switch it on and off based upon whether one of the categories of items in our inventory has fewer than two items left.
Building the circuit – a recap
We will quickly recap on setting up the circuit for the LED. The following diagram demonstrates this again:
![](https://static.packt-cdn.com/products/9781784397975/graphics/B04058_11_01.jpg)
Here, we have connected an LED to a 270 Ohm resistor and hooked this up to GPIO pin 4. Finally, the LED's other leg is connected to the ground pin.
This circuit is now ready to be controlled from our Flask application.
Integrating with our Python app
Now we have the circuit up and running again, we can hook it into our existing Python functions and have them switch the LED on and off.
What we will need to do is trigger the LED to switch on when we edit an item if the count is now less than 2
, that is, there are 0 or 1 items...