Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lexo2018
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
starx
Lexo2018
Merge requests
!1
Data Logging
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Data Logging
patch-1
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Open
kamako
requested to merge
patch-1
into
master
6 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Compare
master
master (HEAD)
and
latest version
latest version
2a805ceb
1 commit,
6 years ago
1 file
+
64
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Starx.m
0 → 100644
+
64
−
0
Options
%% Acquire and analyze data from a temperature sensor
%% Connect to Arduino
% Use the arduino command to connect to an Arduino device.
clear
();
a
=
arduino
;
filename
=
input
(
'Please enter a filename \n'
,
's'
)
figure
h
=
animatedline
;
h
.
Color
=
'red'
;
i
=
animatedline
;
i
.
Color
=
'blue'
;
ax
=
gca
;
ax
.
YGrid
=
'on'
;
ax
.
YLim
=
[
0
5
];
stop
=
false
;
startTime
=
datetime
(
'now'
);
while
~
stop
stop
=
readDigitalPin
(
a
,
'D12'
);
end
writeDigitalPin
(
a
,
'D13'
,
1
)
pause
(
0.5
)
stop
=
false
;
while
~
stop
% Read current voltage value
v0
=
readVoltage
(
a
,
'A0'
);
v1
=
readVoltage
(
a
,
'A1'
);
% Calculate temperature from voltage (based on data sheet)
% Get current time
t
=
datetime
(
'now'
)
-
startTime
;
% Add points to animation
addpoints
(
h
,
datenum
(
t
),
v0
)
addpoints
(
i
,
datenum
(
t
),
v1
)
% Update axes
ax
.
XLim
=
datenum
([
t
-
seconds
(
15
)
t
]);
datetick
(
'x'
,
'keeplimits'
)
drawnow
% Check stop condition
stop
=
readDigitalPin
(
a
,
'D12'
);
end
writeDigitalPin
(
a
,
'D13'
,
0
)
%% Plot the recorded data
[
timeLogs
,
EKG
]
=
getpoints
(
h
);
[
throwaway
,
Pot
]
=
getpoints
(
i
);
timeSecs
=
(
timeLogs
-
timeLogs
(
1
))
*
24
*
3600
;
% figure
% plot(timeSecs,tempLogs)
% xlabel('Elapsed time (sec)')
% ylabel('Temperature (\circF)')
%% Save results to a file
T
=
table
(
timeSecs
',EKG'
,
Pot
','
VariableNames
',{'
Time_sec
','
EKG
','
Pot
'
});
filename
=
strcat
(
filename
,
'.xlsx'
);
% Write table to file
writetable
(
T
,
filename
)
% Print confirmation to command line
fprintf
(
'Results table with %g temperature measurements saved to file %s\n'
,
...
length
(
timeSecs
),
filename
)
Loading