Thank you so much! This solved the issue I was having, I just needed to delete the state_off row and the fourth else-if, and change all of the states that were in $Self to % Ignore% and the program ran flawlessly.
Help with State Transition Table
4 views (last 30 days)
Show older comments
Greetings, I am diong a project where I am creating an air piano inside simulink with my arduino uno board. The table is for lighting three LED lights based on different distance inputs from an ultrasound sensor. The output I am currently getting is that only my green LED lights up despite inputting several different distances. any help or tips would be greatly appreciated. I have also included a picture of my blocks diagram in simulink.
0 Comments
Accepted Answer
Joaquin
on 18 Nov 2023
2 Comments
madhan ravi
on 18 Nov 2023
But did you see @Fangjuns answer? The condition that you are using is still wrong.
Fangjun Jiang
on 18 Nov 2023
The below example explains why you got the "correct" result after making the "wrong" changes.
After making the changes your described, please run a simulation where "distance" is fed with a Constant block with value 35. You will see the state stays at Green, which is obviously wrong.
You could attach your model for others to try.
distance=35;
[0<distance<10]
More Answers (1)
Fangjun Jiang
on 17 Nov 2023
Edited: Fangjun Jiang
on 17 Nov 2023
[0<distance<10] is not the correct syntax. Your state stays at the default.
changing all to style [0<distance && distance<10] should resolve the issue.
2 Comments
Fangjun Jiang
on 17 Nov 2023
Edited: Fangjun Jiang
on 17 Nov 2023
distance=35;
[0<distance<10]
This is equivalant to
(0<distance) < 10
madhan ravi
on 17 Nov 2023
Edited: madhan ravi
on 17 Nov 2023
yes, proper logical and should be used for stateflow conditions in the similar way done in MATLAB
See Also
Categories
Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!