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.
main.cpp@0:a10f79635bf7, 2019-10-05 (annotated)
- Committer:
- sduffield
- Date:
- Sat Oct 05 01:11:21 2019 +0000
- Revision:
- 0:a10f79635bf7
HW1_3_1
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| sduffield | 0:a10f79635bf7 | 1 | #include "mbed.h" |
| sduffield | 0:a10f79635bf7 | 2 | //#include "DebounceIn.h" |
| sduffield | 0:a10f79635bf7 | 3 | |
| sduffield | 0:a10f79635bf7 | 4 | |
| sduffield | 0:a10f79635bf7 | 5 | AnalogIn sensor1(p20); // define the hall and temprature sensors |
| sduffield | 0:a10f79635bf7 | 6 | AnalogIn sensor2(p17); |
| sduffield | 0:a10f79635bf7 | 7 | Serial pc(USBTX, USBRX); |
| sduffield | 0:a10f79635bf7 | 8 | |
| sduffield | 0:a10f79635bf7 | 9 | Timer timer; |
| sduffield | 0:a10f79635bf7 | 10 | |
| sduffield | 0:a10f79635bf7 | 11 | DigitalOut led1(LED1); |
| sduffield | 0:a10f79635bf7 | 12 | DigitalOut led2(LED2); |
| sduffield | 0:a10f79635bf7 | 13 | DigitalOut led3(LED3); |
| sduffield | 0:a10f79635bf7 | 14 | DigitalOut led4(LED4); |
| sduffield | 0:a10f79635bf7 | 15 | |
| sduffield | 0:a10f79635bf7 | 16 | |
| sduffield | 0:a10f79635bf7 | 17 | |
| sduffield | 0:a10f79635bf7 | 18 | int main() { |
| sduffield | 0:a10f79635bf7 | 19 | float time; |
| sduffield | 0:a10f79635bf7 | 20 | float volt1; |
| sduffield | 0:a10f79635bf7 | 21 | float volt2; |
| sduffield | 0:a10f79635bf7 | 22 | float temp; |
| sduffield | 0:a10f79635bf7 | 23 | timer.start(); |
| sduffield | 0:a10f79635bf7 | 24 | while(1) { |
| sduffield | 0:a10f79635bf7 | 25 | time=timer.read(); |
| sduffield | 0:a10f79635bf7 | 26 | volt1=sensor1.read()*3.3; |
| sduffield | 0:a10f79635bf7 | 27 | temp=-1481 + sqrt( 2.1962*pow(10.0,6.0) + (1.8639-volt1)/(3.88*pow(10.0,-6.0)) ); |
| sduffield | 0:a10f79635bf7 | 28 | volt2=sensor2.read()*3.3; |
| sduffield | 0:a10f79635bf7 | 29 | pc.printf("$TTMPL=%f,%f,%f,%f\r\n",time,volt1,temp,volt2); |
| sduffield | 0:a10f79635bf7 | 30 | |
| sduffield | 0:a10f79635bf7 | 31 | wait(5); |
| sduffield | 0:a10f79635bf7 | 32 | } |
| sduffield | 0:a10f79635bf7 | 33 | } |
