Change pin mode for Arduino in Simulink
3 次查看(过去 30 天)
显示 更早的评论
I'm trying to compile a Simulink program that uses a stateflow chart with an Arduino board as my target. I keep getting the error: "Both the 'Digital Output' block and the 'Digital Input' block use the pin number 7. Change the value of the parameter 'Pin number' on the 'Digital Output' block, or the value of the parameter 'Pin number' on the 'Digital Input' block so that the parameter conflict is resolved." However, I need to be able to change the pin mode in my application. A pulse has to be sent to the ultrasonic sensor and then it has to wait for a return pulse. I'm not sure how to change the pin mode in Simulink from output to input. Any help on this would be appreciated. Thanks.
0 个评论
采纳的回答
Ryan G
2012-9-21
What's going on is each pin can only do 1 thing, as pin 7 can ONLY be used for output or ONLY be used for input.
Looking at this ultrasound sensor and the code that follows, they are discretely switching the pin 7 later on. There is an answer here which says this cannot be done directly.
There are 2 options as I see it:
1) Instead of using the Simulink I/O blocks, you can write an s-function that will perform the digital i/o
2) Find a sensor that uses 2 pins instead of 1.
You should have the code for the digital I/O already (I think that's what's on the sensor link above) so all you would need to do is implement that via s-function.
8 个评论
Ryan G
2012-9-28
It's great to hear that you worked this out. May I suggest you make an enhancement request since it looks like using the same pin I/O is a common workflow for this type of sensor.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Arduino Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!