How do you make an LED blink 3 times after clicking a button using only a simulink model
55 次查看(过去 30 天)
显示 更早的评论
after a button has been pushed the led has to blink 3 times, how to do this on simulink?
0 个评论
回答(1 个)
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 个评论
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!