Sensor Workshop at ITP
Code
/
Voltage Conversion
void
setup
(
)
{
Serial
.
begin
(
9600
)
;
}
void
loop
(
)
{
// read the value from the sensor:
int
sensorValue
=
analogRead
(
A0
)
;
// convert the reading to volts:
float
voltage
=
(
sensorValue
*
5.0
)
/
1024.0
;
Serial
.
println
(
voltage
)
;
}
[$[Get Code]]
Menu
Home Page
Syllabus
Sensor Reports
Class Notes
Code Samples
Circuit schematics
Resources
Author Profiles
Glossary of terms
RSS feed for this site
Actions
View
Edit
History
Print
Search