Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pico-displayTemperature
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Show more breadcrumbs
abp1g20
pico-displayTemperature
Commits
6202c757
Commit
6202c757
authored
3 years ago
by
abp1g20
Browse files
Options
Downloads
Patches
Plain Diff
Replace main.c
parent
cff37216
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.c
+4
-3
4 additions, 3 deletions
main.c
with
4 additions
and
3 deletions
main.c
+
4
−
3
View file @
6202c757
...
@@ -33,11 +33,11 @@ int main() {
...
@@ -33,11 +33,11 @@ int main() {
//Update temperature display every second
//Update temperature display every second
//Infinite loop
//Infinite loop
while
(
1
)
{
while
(
1
)
{
uint16_t
raw
=
adc_read
();
//Define a variable to store the raw output value from the adc
uint16_t
raw
=
adc_read
();
//Define a variable to store the raw output value from the adc
//Do the conversion
//Do the conversion
const
float
conversion
=
3
.
3
f
/
(
1
<<
12
);
const
float
conversion
=
3
.
3
f
/
(
1
<<
12
);
float
voltage
=
raw
*
conversion
;
// convert raw value to voltage
float
voltage
=
raw
*
conversion
;
// convert raw value to voltage
float
temperature
=
27
-
(
voltage
-
0
.
706
)
/
0
.
001721
;
// convert voltage to temperature value
float
temperature
=
27
-
(
voltage
-
0
.
706
)
/
0
.
001721
;
// convert voltage to temperature value
...
@@ -52,3 +52,4 @@ int main() {
...
@@ -52,3 +52,4 @@ int main() {
//wait 1 sec
//wait 1 sec
sleep_ms
(
1000
);
sleep_ms
(
1000
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment