Build an Out-of-Memory Alarm
Turning an LED on and off using software is an important exercise, but it’s certainly not a very useful project. Usually, you won’t control LEDs manually, but you’ll use them as status indicators. For example, many USB devices use LEDs to show whether they’re reading or writing data at the moment.
In this section, we’ll use three LEDs as status indicators for the Pi’s current memory usage. The LEDs will have the same colors as a traffic light. If the Pi’s memory is critically low, we’ll turn on the red light. If a lot of memory is available, we’ll turn on the green light. Otherwise, it will be yellow.
In Figure 49, Memory alarm circuit diagram, you can see the circuit of the memory alarm. In Figure 50, The ...
Get Raspberry Pi, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.