library for using LM61.
Dependents: Thermometer TMP36_Anlog_temperature_read
Please connect AnalogIn pin with vout pin of LM61.
LM61.h@2:7fe5f722fc6b, 2015-03-20 (annotated)
- Committer:
- Match314
- Date:
- Fri Mar 20 12:33:04 2015 +0000
- Revision:
- 2:7fe5f722fc6b
- Parent:
- 1:82efa0dea908
Apache License 2.0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Match314 | 0:ba8b3a1b95ac | 1 | /* mbed library for LM61 |
Match314 | 2:7fe5f722fc6b | 2 | * |
Match314 | 2:7fe5f722fc6b | 3 | * Copyright (C) 2015 Match |
Match314 | 2:7fe5f722fc6b | 4 | * |
Match314 | 2:7fe5f722fc6b | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Match314 | 2:7fe5f722fc6b | 6 | * you may not use this file except in compliance with the License. |
Match314 | 2:7fe5f722fc6b | 7 | * You may obtain a copy of the License at |
Match314 | 0:ba8b3a1b95ac | 8 | * |
Match314 | 2:7fe5f722fc6b | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Match314 | 2:7fe5f722fc6b | 10 | * |
Match314 | 2:7fe5f722fc6b | 11 | * Unless required by applicable law or agreed to in writing, software |
Match314 | 2:7fe5f722fc6b | 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
Match314 | 2:7fe5f722fc6b | 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Match314 | 2:7fe5f722fc6b | 14 | * See the License for the specific language governing permissions and |
Match314 | 2:7fe5f722fc6b | 15 | * limitations under the License. |
Match314 | 0:ba8b3a1b95ac | 16 | */ |
Match314 | 0:ba8b3a1b95ac | 17 | |
Match314 | 0:ba8b3a1b95ac | 18 | #ifndef LM61_H_2014_12_31 |
Match314 | 0:ba8b3a1b95ac | 19 | #define LM61_H_2014_12_31 |
Match314 | 0:ba8b3a1b95ac | 20 | |
Match314 | 0:ba8b3a1b95ac | 21 | #include "mbed.h" |
Match314 | 0:ba8b3a1b95ac | 22 | |
Match314 | 1:82efa0dea908 | 23 | /** Get temperature from LM61 class |
Match314 | 0:ba8b3a1b95ac | 24 | * |
Match314 | 0:ba8b3a1b95ac | 25 | * Example: |
Match314 | 0:ba8b3a1b95ac | 26 | * @code |
Match314 | 0:ba8b3a1b95ac | 27 | * #include "LM61.h" |
Match314 | 0:ba8b3a1b95ac | 28 | * #include "mbed.h" |
Match314 | 0:ba8b3a1b95ac | 29 | * |
Match314 | 0:ba8b3a1b95ac | 30 | * LM61 lm61(dp4, 3.0f); |
Match314 | 0:ba8b3a1b95ac | 31 | * Serial pc(USBTX, USBRX); |
Match314 | 0:ba8b3a1b95ac | 32 | * |
Match314 | 0:ba8b3a1b95ac | 33 | * int main() { |
Match314 | 0:ba8b3a1b95ac | 34 | * float temp; |
Match314 | 0:ba8b3a1b95ac | 35 | * |
Match314 | 0:ba8b3a1b95ac | 36 | * while(1) { |
Match314 | 0:ba8b3a1b95ac | 37 | * temp = lm61.GetTemp(); |
Match314 | 0:ba8b3a1b95ac | 38 | * pc.printf("Temperature : %5.1fdeg\n", temp); |
Match314 | 0:ba8b3a1b95ac | 39 | * wait(1); |
Match314 | 0:ba8b3a1b95ac | 40 | * } |
Match314 | 0:ba8b3a1b95ac | 41 | * } |
Match314 | 0:ba8b3a1b95ac | 42 | * @endcode |
Match314 | 0:ba8b3a1b95ac | 43 | */ |
Match314 | 0:ba8b3a1b95ac | 44 | class LM61 { |
Match314 | 0:ba8b3a1b95ac | 45 | public: |
Match314 | 0:ba8b3a1b95ac | 46 | |
Match314 | 0:ba8b3a1b95ac | 47 | /** A constructor of LM61 class |
Match314 | 0:ba8b3a1b95ac | 48 | * @param lm61 pin connected to vout of LM61 |
Match314 | 0:ba8b3a1b95ac | 49 | * @param vcc Vcc voltage |
Match314 | 0:ba8b3a1b95ac | 50 | */ |
Match314 | 0:ba8b3a1b95ac | 51 | LM61(PinName lm61, float vcc=3.3f); |
Match314 | 0:ba8b3a1b95ac | 52 | |
Match314 | 0:ba8b3a1b95ac | 53 | /** Get temperature from LM61 |
Match314 | 0:ba8b3a1b95ac | 54 | * @return temperature from LM61 in degree |
Match314 | 0:ba8b3a1b95ac | 55 | */ |
Match314 | 0:ba8b3a1b95ac | 56 | float GetTemp(); |
Match314 | 0:ba8b3a1b95ac | 57 | |
Match314 | 0:ba8b3a1b95ac | 58 | private: |
Match314 | 0:ba8b3a1b95ac | 59 | AnalogIn _lm61; |
Match314 | 0:ba8b3a1b95ac | 60 | float _vcc; |
Match314 | 0:ba8b3a1b95ac | 61 | }; |
Match314 | 0:ba8b3a1b95ac | 62 | |
Match314 | 0:ba8b3a1b95ac | 63 | |
Match314 | 0:ba8b3a1b95ac | 64 | #endif // LM61_H_2014_12_31 |