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:a00fb5d3f693, 2018-05-24 (annotated)
- Committer:
- Bahirah
- Date:
- Thu May 24 05:30:16 2018 +0000
- Revision:
- 0:a00fb5d3f693
ADC_SWITCH
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Bahirah | 0:a00fb5d3f693 | 1 | |
| Bahirah | 0:a00fb5d3f693 | 2 | #include "mbed.h" |
| Bahirah | 0:a00fb5d3f693 | 3 | #include "TextLCD.h" |
| Bahirah | 0:a00fb5d3f693 | 4 | |
| Bahirah | 0:a00fb5d3f693 | 5 | TextLCD lcd(D8, D9, D4, D5, D6, D7); |
| Bahirah | 0:a00fb5d3f693 | 6 | Serial pc(USBTX, USBRX); |
| Bahirah | 0:a00fb5d3f693 | 7 | AnalogIn Ain(PC_3); |
| Bahirah | 0:a00fb5d3f693 | 8 | DigitalIn pb (PA_12); |
| Bahirah | 0:a00fb5d3f693 | 9 | float ADCdata; |
| Bahirah | 0:a00fb5d3f693 | 10 | |
| Bahirah | 0:a00fb5d3f693 | 11 | int main() { |
| Bahirah | 0:a00fb5d3f693 | 12 | lcd.cls(); |
| Bahirah | 0:a00fb5d3f693 | 13 | lcd.locate(1,0); |
| Bahirah | 0:a00fb5d3f693 | 14 | lcd.printf ("Temp Measure"); |
| Bahirah | 0:a00fb5d3f693 | 15 | |
| Bahirah | 0:a00fb5d3f693 | 16 | while (1) |
| Bahirah | 0:a00fb5d3f693 | 17 | { |
| Bahirah | 0:a00fb5d3f693 | 18 | ADCdata=Ain; |
| Bahirah | 0:a00fb5d3f693 | 19 | ADCdata=ADCdata*100; |
| Bahirah | 0:a00fb5d3f693 | 20 | |
| Bahirah | 0:a00fb5d3f693 | 21 | |
| Bahirah | 0:a00fb5d3f693 | 22 | if (pb == 0) |
| Bahirah | 0:a00fb5d3f693 | 23 | { |
| Bahirah | 0:a00fb5d3f693 | 24 | lcd.locate (0,1); |
| Bahirah | 0:a00fb5d3f693 | 25 | lcd.printf ("Cel:"); |
| Bahirah | 0:a00fb5d3f693 | 26 | |
| Bahirah | 0:a00fb5d3f693 | 27 | lcd.locate (4,1); |
| Bahirah | 0:a00fb5d3f693 | 28 | lcd.printf ("%2.2f", ADCdata); |
| Bahirah | 0:a00fb5d3f693 | 29 | |
| Bahirah | 0:a00fb5d3f693 | 30 | } |
| Bahirah | 0:a00fb5d3f693 | 31 | else if (pb == 1) |
| Bahirah | 0:a00fb5d3f693 | 32 | { |
| Bahirah | 0:a00fb5d3f693 | 33 | |
| Bahirah | 0:a00fb5d3f693 | 34 | lcd.locate (8,1); |
| Bahirah | 0:a00fb5d3f693 | 35 | lcd.printf ("Fah:", ADCdata); |
| Bahirah | 0:a00fb5d3f693 | 36 | |
| Bahirah | 0:a00fb5d3f693 | 37 | lcd.locate (12,1); |
| Bahirah | 0:a00fb5d3f693 | 38 | lcd.printf ("%2.2f", ADCdata); |
| Bahirah | 0:a00fb5d3f693 | 39 | |
| Bahirah | 0:a00fb5d3f693 | 40 | } |
| Bahirah | 0:a00fb5d3f693 | 41 | wait (0.5); |
| Bahirah | 0:a00fb5d3f693 | 42 | } |
| Bahirah | 0:a00fb5d3f693 | 43 | } |