
Temp36 HelloWorld Example for WIZwiki-W7500
Dependencies: mbed
Fork of AnalogIn_HelloWorld_WIZwiki-W7500 by
main.cpp@8:7be9fa8531b5, 2016-02-03 (annotated)
- Committer:
- IOP
- Date:
- Wed Feb 03 07:29:45 2016 +0000
- Revision:
- 8:7be9fa8531b5
- Parent:
- 6:0bbd259454d0
update mbed lib
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
justinkim | 4:46410fc301ea | 1 | /* Analog Input "Temp36" Temperature Sensor Example Program */ |
sam_grove | 0:101a12a915c6 | 2 | |
sam_grove | 0:101a12a915c6 | 3 | #include "mbed.h" |
sam_grove | 0:101a12a915c6 | 4 | |
justinkim | 4:46410fc301ea | 5 | // Initialize a pins to perform analog input fucntions |
IOP | 8:7be9fa8531b5 | 6 | AnalogIn ain(A0); // connect A0(WIZwiki-W7500) to Vout(Temp36) |
sam_grove | 0:101a12a915c6 | 7 | |
sam_grove | 0:101a12a915c6 | 8 | int main(void) |
sam_grove | 0:101a12a915c6 | 9 | { |
justinkim | 4:46410fc301ea | 10 | while (1) |
justinkim | 4:46410fc301ea | 11 | { |
IOP | 8:7be9fa8531b5 | 12 | float V = ain.read() * 3.3; // connect Vs(Temp36) to 3.3V(WIZwiki-W7500) |
IOP | 8:7be9fa8531b5 | 13 | //float V = ain.read() * 5; // connect Vs(Temp36) to 5V(WIZwiki-W7500) |
sam_grove | 0:101a12a915c6 | 14 | |
IOP | 8:7be9fa8531b5 | 15 | float tempC = (V - 0.5) * 100; // calculate temperature C |
IOP | 8:7be9fa8531b5 | 16 | float tempF = (tempC * 9 / 5) + 32.0; // calculate temperature F |
justinkim | 4:46410fc301ea | 17 | |
justinkim | 4:46410fc301ea | 18 | printf("tempC value : %5.2f C \r\n", tempC); |
justinkim | 4:46410fc301ea | 19 | printf("tempF value : %5.2f F \r\n", tempF); |
justinkim | 4:46410fc301ea | 20 | |
joon874 | 2:5f564266c94f | 21 | wait(1.0); |
sam_grove | 0:101a12a915c6 | 22 | } |
sam_grove | 0:101a12a915c6 | 23 | } |
joon874 | 3:abab0082e271 | 24 | |
joon874 | 3:abab0082e271 | 25 | |
joon874 | 3:abab0082e271 | 26 | |
joon874 | 3:abab0082e271 | 27 | |
joon874 | 3:abab0082e271 | 28 | |
joon874 | 3:abab0082e271 | 29 | |
joon874 | 3:abab0082e271 | 30 | |
joon874 | 3:abab0082e271 | 31 | |
joon874 | 3:abab0082e271 | 32 |