How do you make an LED blink 3 times after clicking a button using only a simulink model

55 ビュー (過去 30 日間)
Sergio Salido
Sergio Salido 2022 年 11 月 7 日
コメント済み: Magdalena 2024 年 5 月 3 日
after a button has been pushed the led has to blink 3 times, how to do this on simulink?

回答 (1 件)

Isaac Rose
Isaac Rose 2022 年 11 月 9 日
You can accomplish this by building a Stateflow chart within your Simulink model. The shipped example here demonstrates how you can transition between states using delays:
For example, you could have a ‘Blinking’ subchart with an ‘On’ state and an ‘Off’ state, and execute the statement “after(0.5,sec)” along the transitions between the two states to simulate blinking. This YouTube video shows how to do this:
You could then trigger the chart in response to a button being pressed using function calls or edge triggers, as explained here:
The video here would be good to watch if you are new to using Stateflow:
Alternatively, you could simulate blinking without using Stateflow by using a Pulse Generator block to alternate between values of 0 and 1. You can use an Enabled Subsystem or Switch block to control when the pulsed signal is sent to the LED, as opposed to a Constant 0 signal when the LED should be off. You can also use an On-Off Delay block to control how long the enabling signal stays active after the button is pressed, i.e., you could configure the blinking light to blink for 6 seconds by setting the OFF delay time to 6 s and adjusting the parameters of the pulse generator to blink 3 times.
  1 件のコメント
Magdalena
Magdalena 2024 年 5 月 3 日
Can you give more detiled exlanation for the example with the Pulse Generator?

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeComplex Logic についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by