From the course: Learning Arduino: Interfacing with Analog Devices

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Coding to read the temperature sensor

Coding to read the temperature sensor - Arduino Tutorial

From the course: Learning Arduino: Interfacing with Analog Devices

Start my 1-month free trial

Coding to read the temperature sensor

- [Instructor] Go ahead and open a new file to start coding for the temperature sensor that we have. The very first thing that I need to do, is I need to initialize where is this analog sensor connected to. I'll go ahead and I'll put in an integer value: "analogPin", (keyboard sounds) and that is connected to A0. And I'll create two variables- float variables (keyboard sounds) for voltage out and one for the temperature. (keyboard sounds) The second thing that I need to do is go to the void setup and initialize the serial begin. Now there is a code within Arduino to specify the analog reference for the temperature sensor that we're using. If you go to the website, there is the command that's called "analogReference" and there are different ways that you can implement the analog reference. For our case, We need to specify that the maximum voltage, that we've received from the analog sensor, is 5 volts. In our case, We are going to use a default. There are many other ways that you can…

Contents