![](/media/cache/group/IOP_DtuxQTL.jpg.50x50_q85.jpg)
Temp36 HelloWorld Example for WIZwiki-W7500
Dependencies: mbed
Fork of AnalogIn_HelloWorld_WIZwiki-W7500 by
main.cpp@4:46410fc301ea, 2015-07-06 (annotated)
- Committer:
- justinkim
- Date:
- Mon Jul 06 01:30:22 2015 +0000
- Revision:
- 4:46410fc301ea
- Parent:
- 3:abab0082e271
- Child:
- 5:2b825fae647d
Temp36 HelloWorld Example for WIZwiki-W7500
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 |
justinkim | 4:46410fc301ea | 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 | { |
justinkim | 4:46410fc301ea | 12 | float V = ain.read() * 3.3; // connect Vs(Temp36) to 3.3V(WIZwiki-W7500) |
justinkim | 4:46410fc301ea | 13 | //float V = ain.read() * 5; // connect Vs(Temp36) to 5V(WIZwiki-W7500) |
sam_grove | 0:101a12a915c6 | 14 | |
justinkim | 4:46410fc301ea | 15 | float tempC = (V-0.5) * 100; // calculate temperature C |
justinkim | 4:46410fc301ea | 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 |