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.
We will quickly recap on setting up the circuit for the LED. The following diagram demonstrates this again:
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.