Tyler Weaver / TMP36 GZ

Dependents:   HARP2 HARP3 Thermostat_NucleoF401 4180Lab4_p1 ... more

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TMP36GZ.cpp Source File

TMP36GZ.cpp

00001 /*
00002 * Copyright (c) 2012 Tyler Weaver, MIT License
00003 *
00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005 * and associated documentation files (the "Software"), to deal in the Software without restriction,
00006 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00007 
00008 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00009 * furnished to do so, subject to the following conditions:
00010 *
00011 * The above copyright notice and this permission notice shall be included in all copies or
00012 * substantial portions of the Software.
00013 *
00014 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00015 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00016 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00017 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00018 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00019 */
00020 #include "TMP36GZ.h"
00021 
00022 TMP36GZ::TMP36GZ(PinName pin)
00023 {
00024     input_pin_ = new AnalogIn(pin);
00025 }
00026 
00027 float TMP36GZ::sample()
00028 {
00029     return input_pin_->read() * 330.0 - 50.0;
00030 }
00031 
00032 float TMP36GZ::sample_f()
00033 {
00034     return sample() * 1.8 + 32.0;
00035 }