Timer1's stopFcn to start Timer2

I'm trying to figure out how i can use timers to control the amount of time between I set a pin HIGH or LOW on an Arduino.
I created 2 timers (each with a start delay of 3 seconds):
tHigh = timer('StartDelay',3);
tLow = timer('StartDelay',3);
And assigned the TimerFcn to set the pin HIGH and LOW:
tHigh.TimerFcn = @(x,y) a.writeDigitalPin(8,1);
tLow.TimerFcn = @(x,y) a.writeDigitalPin(8,0);
When tHigh stop - I want to start tLow:
tHigh.StopFcn = @(x)start(tLow);
My problem is that i get the following error message, when start(tHigh) is called:
Error while evaluating StopFcn for timer
Does anybody have a clue whats wrong?
Thanks in advance :)

 採用された回答

Walter Roberson
Walter Roberson 2015 年 12 月 10 日

0 投票

"If you specify this property using a function handle, when MATLAB executes the callback it passes the timer object and an event structure to the callback function. The event structure contains the type of event in the Type field and the time of the event in the Data field."
That is two parameters, but your StopFcn is specified as only accepting one parameter.

1 件のコメント

Anders
Anders 2015 年 12 月 10 日
Facepalm..
It works now. Thanks a lot. :)
Looking forward to test how timers will work in my final implementation.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Support Package for Arduino Hardware についてさらに検索

製品

質問済み:

2015 年 12 月 10 日

コメント済み:

2015 年 12 月 10 日

Community Treasure Hunt

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

Start Hunting!

Translated by