Gradually Changing LED Intensity

5 Ansichten (letzte 30 Tage)
Jacob Rhodes
Jacob Rhodes am 29 Jun. 2022
Beantwortet: Kanishk am 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!

Antworten (1)

Kanishk
Kanishk am 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!

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by