Gradually Changing LED Intensity

7 visualizzazioni (ultimi 30 giorni)
Jacob Rhodes
Jacob Rhodes il 29 Giu 2022
Risposto: Kanishk il 24 Gen 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!

Risposte (1)

Kanishk
Kanishk il 24 Gen 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!

Categorie

Scopri di più su Simulink in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by