Filter löschen
Filter löschen

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

30 Ansichten (letzte 30 Tage)
after a button has been pushed the led has to blink 3 times, how to do this on simulink?

Antworten (1)

Isaac Rose
Isaac Rose am 9 Nov. 2022
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.

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by