How can I make a loop for sending a signal in form of step, using only Matlab and Arduino Mega 2560 (not Simulink nor step function itself)?

1 次查看(过去 30 天)
Hi everyone
I'm working with arduino Mega 2560 and Matlab and I'm using the function "writePWMVoltage" for sending a specific voltage to outside.
My issue is the following situation:
I don't know how to make a loop for creating a "step" signal (without using the function of matlab itself, nor Simulink).
For example, I want to send a voltage of 2 volts since t = 0 to 30 seconds, and from the instant 31 second, send a voltage of 2.5 Volts (If you see, this is like a "step function")
I'm trying with the functions "for", "while", and I don't know how to get this thing, it appears some errors, I'm a amateur in programation.
Please help me.
Thank you so much for reading and answer me in advance.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by