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.
Fork of Task411 by
main.cpp@0:b2188dcbd1b1, 2015-09-24 (annotated)
- Committer:
- noutram
- Date:
- Thu Sep 24 12:28:07 2015 +0000
- Revision:
- 0:b2188dcbd1b1
- Child:
- 3:00b294a944de
Initial version 24-09-2015
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| noutram | 0:b2188dcbd1b1 | 1 | #include "mbed.h" |
| noutram | 0:b2188dcbd1b1 | 2 | |
| noutram | 0:b2188dcbd1b1 | 3 | //Global objects |
| noutram | 0:b2188dcbd1b1 | 4 | BusOut binaryOutput(D5, D6, D7); //Outputs as an integer |
| noutram | 0:b2188dcbd1b1 | 5 | |
| noutram | 0:b2188dcbd1b1 | 6 | DigitalIn SW1(D3); |
| noutram | 0:b2188dcbd1b1 | 7 | DigitalIn SW2(D4); |
| noutram | 0:b2188dcbd1b1 | 8 | |
| noutram | 0:b2188dcbd1b1 | 9 | AnalogIn AIN(A0); |
| noutram | 0:b2188dcbd1b1 | 10 | float fVin = 0.0; |
| noutram | 0:b2188dcbd1b1 | 11 | |
| noutram | 0:b2188dcbd1b1 | 12 | //Main function |
| noutram | 0:b2188dcbd1b1 | 13 | int main() { |
| noutram | 0:b2188dcbd1b1 | 14 | |
| noutram | 0:b2188dcbd1b1 | 15 | |
| noutram | 0:b2188dcbd1b1 | 16 | while(1) { |
| noutram | 0:b2188dcbd1b1 | 17 | |
| noutram | 0:b2188dcbd1b1 | 18 | //Read ADC |
| noutram | 0:b2188dcbd1b1 | 19 | fVin = AIN; |
| noutram | 0:b2188dcbd1b1 | 20 | |
| noutram | 0:b2188dcbd1b1 | 21 | //Write to terminal |
| noutram | 0:b2188dcbd1b1 | 22 | printf("Analog input = %6.4f\n", fVin); //3 decimal places, fieldwidth=5 |
| noutram | 0:b2188dcbd1b1 | 23 | |
| noutram | 0:b2188dcbd1b1 | 24 | //Wait |
| noutram | 0:b2188dcbd1b1 | 25 | wait(0.5); |
| noutram | 0:b2188dcbd1b1 | 26 | |
| noutram | 0:b2188dcbd1b1 | 27 | } //end while(1) |
| noutram | 0:b2188dcbd1b1 | 28 | } //end main |
