Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
main.cpp@6:2d1063039aab, 2015-11-17 (annotated)
- Committer:
- dculver
- Date:
- Tue Nov 17 22:29:22 2015 +0000
- Revision:
- 6:2d1063039aab
- Parent:
- 5:67e154e155e8
changed Jonathan to Danny
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bcostm | 0:c2d1ad5059da | 1 | #include "mbed.h" |
bcostm | 0:c2d1ad5059da | 2 | |
bcostm | 0:c2d1ad5059da | 3 | AnalogIn analog_value(A0); |
bcostm | 0:c2d1ad5059da | 4 | |
bcostm | 1:0490a15c76e4 | 5 | DigitalOut led(LED1); |
jchari | 3:b8aaacdd726e | 6 | Serial pc(USBTX, USBRX); // tx, rx |
bcostm | 1:0490a15c76e4 | 7 | |
jchari | 3:b8aaacdd726e | 8 | |
bcostm | 0:c2d1ad5059da | 9 | int main() { |
bcostm | 1:0490a15c76e4 | 10 | float meas; |
jchari | 3:b8aaacdd726e | 11 | pc.printf("AnalogIn example: "); |
bcostm | 1:0490a15c76e4 | 12 | while(1) { |
bcostm | 1:0490a15c76e4 | 13 | meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0) |
bcostm | 1:0490a15c76e4 | 14 | meas = meas * 3300; // Change the value to be in the 0 to 3300 range |
jchari | 3:b8aaacdd726e | 15 | pc.printf("measure = %.0f mV\r\n", meas); |
jchari | 3:b8aaacdd726e | 16 | if (meas >= 450 ) { // If the value is greater than 2V then switch the LED on |
jchari | 3:b8aaacdd726e | 17 | pc.printf("Thermistor is being worn\r\n"); |
bcostm | 1:0490a15c76e4 | 18 | } |
jchari | 3:b8aaacdd726e | 19 | if (meas < 450) { // If the value is greater than 2V then switch the LED on |
jchari | 3:b8aaacdd726e | 20 | pc.printf("Thermistor is at room temperature\r\n"); |
bcostm | 0:c2d1ad5059da | 21 | } |
jchari | 3:b8aaacdd726e | 22 | /*if (meas <= 500 && meas >= 450) { // If the value is greater than 2V then switch the LED on |
jchari | 3:b8aaacdd726e | 23 | pc.printf("Thermistor is in cloth\r\n"); |
jchari | 3:b8aaacdd726e | 24 | }*/ |
jchari | 3:b8aaacdd726e | 25 | wait(1); // 200 ms |
bcostm | 0:c2d1ad5059da | 26 | } |
bcostm | 0:c2d1ad5059da | 27 | } |
nkadhikari | 4:b4270fbde211 | 28 | |
dculver | 6:2d1063039aab | 29 | //Danny changes ;asdkfj;kasdjfafklsdjfkljsdkljaf |