Can someone help me make a simple coding?

조회 수: 5 (최근 30일)
Jose Arias
Jose Arias 2020년 12월 1일
답변: Image Analyst 2022년 6월 11일
I need help making a code that sends you a message “you got mail” after weight is applied to a pressure plate for more than 20 seconds. I know it’s a fairly simple code but I suck at coding and my professor didn’t help much this semester as she’s the worst professor I’ve ever had and the class has reported her to the dean.
  댓글 수: 1
Mathieu NOE
Mathieu NOE 2020년 12월 2일
hello
so , have you already starting to write a code ?

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2022년 6월 11일
Try this
startTime = tic
maxTime = 300; % seconds = 5 minutes
underPressure = false;
while toc(startTime) < maxTime
pressure = GetPresure(); % Somehow ask your device for the the current pressure.
if pressure > someThreshold
underPressure = true;
elapsedSeconds = toc(startTime);
if elapsedSeconds >= 20
uiwait(helpdlg("You've got mail!"))
break;
end
else
underPressure = false;
startTime = tic; % Reset clock.
end
end

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by