Hardware & IoTLesson 102Free preview
RasPi Flowing LEDs
This lesson is part of Node.js · All levels
Summary
This lesson developed the LED project into a flowing effect that wipes out several LEDs in a row. You'll learn the setup of many pins through arrays, string repetitions, and precise timing. This project trains the organization of the code to control multiple outputs at once.
Key points
- List some LEDs (e.g. GPIO 17, 27, 22, 5, 6) in the array of Gpio objects.
- The back and forth is done with two repetitions: from start to finish and vice versa.
- Adjust the interval (e.g. 150 ms) for a good viewable spinning speed.
- Turn off all LEDs before turning on the next LED to keep the effect clean.
- Export all pins at the end of the program; use the util function to turn them all off at once.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.