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@0:18e57ab7c8b8, 2019-03-08 (annotated)
- Committer:
- guillaume6544
- Date:
- Fri Mar 08 12:21:43 2019 +0000
- Revision:
- 0:18e57ab7c8b8
temp
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| guillaume6544 | 0:18e57ab7c8b8 | 1 | #include "mbed.h" |
| guillaume6544 | 0:18e57ab7c8b8 | 2 | |
| guillaume6544 | 0:18e57ab7c8b8 | 3 | /*------------------------------------------------------------------------------ |
| guillaume6544 | 0:18e57ab7c8b8 | 4 | Before to use this example, ensure that you an hyperterminal installed on your |
| guillaume6544 | 0:18e57ab7c8b8 | 5 | computer. More info here: https://developer.mbed.org/handbook/Terminals |
| guillaume6544 | 0:18e57ab7c8b8 | 6 | |
| guillaume6544 | 0:18e57ab7c8b8 | 7 | The default serial comm port uses the SERIAL_TX and SERIAL_RX pins (see their |
| guillaume6544 | 0:18e57ab7c8b8 | 8 | definition in the PinNames.h file). |
| guillaume6544 | 0:18e57ab7c8b8 | 9 | |
| guillaume6544 | 0:18e57ab7c8b8 | 10 | The default serial configuration in this case is 9600 bauds, 8-bit data, no parity |
| guillaume6544 | 0:18e57ab7c8b8 | 11 | |
| guillaume6544 | 0:18e57ab7c8b8 | 12 | If you want to change the baudrate for example, you have to redeclare the |
| guillaume6544 | 0:18e57ab7c8b8 | 13 | serial object in your code: |
| guillaume6544 | 0:18e57ab7c8b8 | 14 | |
| guillaume6544 | 0:18e57ab7c8b8 | 15 | Serial pc(SERIAL_TX, SERIAL_RX); |
| guillaume6544 | 0:18e57ab7c8b8 | 16 | |
| guillaume6544 | 0:18e57ab7c8b8 | 17 | Then, you can modify the baudrate and print like this: |
| guillaume6544 | 0:18e57ab7c8b8 | 18 | |
| guillaume6544 | 0:18e57ab7c8b8 | 19 | pc.baud(115200); |
| guillaume6544 | 0:18e57ab7c8b8 | 20 | pc.printf("Hello World !\n"); |
| guillaume6544 | 0:18e57ab7c8b8 | 21 | ------------------------------------------------------------------------------*/ |
| guillaume6544 | 0:18e57ab7c8b8 | 22 | |
| guillaume6544 | 0:18e57ab7c8b8 | 23 | DigitalOut led(LED1); |
| guillaume6544 | 0:18e57ab7c8b8 | 24 | |
| guillaume6544 | 0:18e57ab7c8b8 | 25 | int main() |
| guillaume6544 | 0:18e57ab7c8b8 | 26 | { |
| guillaume6544 | 0:18e57ab7c8b8 | 27 | AnalogIn LM35(A2); |
| guillaume6544 | 0:18e57ab7c8b8 | 28 | float temperature; |
| guillaume6544 | 0:18e57ab7c8b8 | 29 | |
| guillaume6544 | 0:18e57ab7c8b8 | 30 | |
| guillaume6544 | 0:18e57ab7c8b8 | 31 | |
| guillaume6544 | 0:18e57ab7c8b8 | 32 | while(1) { |
| guillaume6544 | 0:18e57ab7c8b8 | 33 | wait(1); // 1 second |
| guillaume6544 | 0:18e57ab7c8b8 | 34 | temperature = LM35.read(); |
| guillaume6544 | 0:18e57ab7c8b8 | 35 | temperature = temperature*3.685503686*100; |
| guillaume6544 | 0:18e57ab7c8b8 | 36 | printf("Température = %f \n\r",temperature); |
| guillaume6544 | 0:18e57ab7c8b8 | 37 | } |
| guillaume6544 | 0:18e57ab7c8b8 | 38 | } |