simple temperature sensor

Dependents:   HARP2 HARP3 Thermostat_NucleoF401 4180Lab4_p1 ... more

Committer:
tylerjw
Date:
Thu Sep 20 23:33:38 2012 +0000
Revision:
8:2b0feb7bdebc
Parent:
4:24ce620f145c
0.9

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tylerjw 8:2b0feb7bdebc 1 /*
tylerjw 0:2bfb76da015b 2 * Copyright (c) 2012 Tyler Weaver, MIT License
tylerjw 0:2bfb76da015b 3 *
tylerjw 0:2bfb76da015b 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
tylerjw 0:2bfb76da015b 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
tylerjw 0:2bfb76da015b 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
tylerjw 0:2bfb76da015b 7
tylerjw 0:2bfb76da015b 8 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
tylerjw 0:2bfb76da015b 9 * furnished to do so, subject to the following conditions:
tylerjw 0:2bfb76da015b 10 *
tylerjw 0:2bfb76da015b 11 * The above copyright notice and this permission notice shall be included in all copies or
tylerjw 0:2bfb76da015b 12 * substantial portions of the Software.
tylerjw 0:2bfb76da015b 13 *
tylerjw 0:2bfb76da015b 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
tylerjw 0:2bfb76da015b 15 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
tylerjw 0:2bfb76da015b 16 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
tylerjw 0:2bfb76da015b 17 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tylerjw 0:2bfb76da015b 18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tylerjw 0:2bfb76da015b 19 */
tylerjw 0:2bfb76da015b 20 #include "TMP36GZ.h"
tylerjw 0:2bfb76da015b 21
tylerjw 0:2bfb76da015b 22 TMP36GZ::TMP36GZ(PinName pin)
tylerjw 0:2bfb76da015b 23 {
tylerjw 0:2bfb76da015b 24 input_pin_ = new AnalogIn(pin);
tylerjw 0:2bfb76da015b 25 }
tylerjw 0:2bfb76da015b 26
tylerjw 0:2bfb76da015b 27 float TMP36GZ::sample()
tylerjw 0:2bfb76da015b 28 {
tylerjw 0:2bfb76da015b 29 return input_pin_->read() * 330.0 - 50.0;
tylerjw 0:2bfb76da015b 30 }
tylerjw 0:2bfb76da015b 31
tylerjw 0:2bfb76da015b 32 float TMP36GZ::sample_f()
tylerjw 0:2bfb76da015b 33 {
tylerjw 0:2bfb76da015b 34 return sample() * 1.8 + 32.0;
tylerjw 0:2bfb76da015b 35 }