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 Exchange에서 MATLAB 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