CODESYS Example: Knight Rider
This tutorial explains how to create a Knight Rider effect on the LEDs of a RevPi Compact. The digital output LEDs flash sequentially from left to right and back, replicating the iconic light effect.
Prerequisites
Hardware
✓ RevPi Compact
For detailed instructions about how to set up your system, see Getting Started.
Software
✓ CODESYS Development System is installed on your PC
To ensure a compatible system with suitable software, see CODESYS System Requirements.
Overview
The Knight Rider effect is achieved by:
▷ Configure AI Channel 1 on the RevPi Compact for the 0–10 V range in the Parameters tab.
▷ Use these two tasks:
-
POU_AdjustSpeed: Sets the time interval for the LED sequence based on the analog input value (AI_CH1).
-
POU_KnightRider: Implements the LED shifting effect on the digital outputs, creating the desired left-to-right and right-to-left pattern.