Gradually Changing LED Intensity

5 views (last 30 days)
Jacob Rhodes
Jacob Rhodes on 29 Jun 2022
Answered: Kanishk on 24 Jan 2025
I'm trying to model a system of LEDs with gradually increasing and decreasing intensities. Are there any blocks or add-ons that anyone is aware of that can help me achieve this behavior? Essentially, I want something similar to the Lamp block, but rather than set values and their accompanying colors, I want something that can change based on the value from 0% to 100% intensity. Thanks in advance!

Answers (1)

Kanishk
Kanishk on 24 Jan 2025
I understand you want to achieve a continuous increase or decrease in intensity using the Lamp block in Simulink. For this, you can utilize the concept of state ranges. By defining multiple states with slightly varying colors, you can simulate a gradual change in intensity.
You can programmatically set the state ranges and colors for the lamp block using this code.
lampStates = []
for i=0:9
st.Value = [i i+1];
st.Color = [0 0 i/10];
lampStates = [lampStates st];
end
set_param(gcs+"/Lamp1", "StateValueType", "Range")
set_param(gcs+"/Lamp1", "StateColors", lampStates)
You can also use a "Circulat Gauge" block in simulink as an alternative if you just want to visualize the values of a signal.
You can learn more about "Lamp" and "Circular gauge" block, by using this command in the MATLAB command window.
web(fullfile(docroot, 'simulink/slref/customlamp.html'))
web(fullfile(docroot, 'simulink/slref/circulargauge.html'))
Hope this helps!

Categories

Find more on Simulink in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!