CODESYS Example: KnightRider
Introduction
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 Requirements
- RevPi Compact
Software Requirements
- CODESYS Development System installed on your PC
Preparation
Hardware Setup:
Tipp: For detailed instructions about how to set up your system, refer to the Getting Started guide.
Software Setup:
note: To ensure a compatible system with suitable software, please refer the following links:
Overview
The Knight Rider effect is achieved by:
-
Configuring AI Channel 1 on the RevPi Compact for the 0–10 V range in the Parameters tab.
-
Using 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.