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.
Revision 1:e3ae2ba0b532, committed 2020-09-16
- Comitter:
- pierreprovent
- Date:
- Wed Sep 16 13:15:42 2020 +0000
- Parent:
- 0:918fdb31e2ce
- Commit message:
- Fichier source pour cours ELE118 Cnam
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Sep 15 11:24:56 2020 +0000
+++ b/main.cpp Wed Sep 16 13:15:42 2020 +0000
@@ -1,12 +1,32 @@
#include "mbed.h"
-DigitalOut myled(LED1);
+/*-----------------------------------------------------------------------
+Before to use this example, ensure that you an hyperterminal installed on your computer.
+More info here: https://developer.mbed.org/handbook/Terminals
+The default serial comm port uses the SERIAL_TX and SERIAL_RX pins (see their definition in the PinNames.h file).
+The default serial configuration in this case is 9600 bauds, 8-bit data, no parity.
+If you want to change the baudrate for example, you have to redeclare the
+serial object in your code:
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+Then, you can modify the baudrate and print like this:
-int main() {
+pc.baud(115200);
+pc.printf("Hello World !\n");
+-------------------------------------------------------------------------*/
+
+DigitalOut led(LED1);
+
+int main()
+{
+ int i = 1;
+
+ printf("Hello World !\n");
+
while(1) {
- myled = 1; // LED is ON
- wait(0.2); // 200 ms
- myled = 0; // LED is OFF
- wait(1.0); // 1 sec
+ wait(1); // 1 second
+ led = !led; // Toggle LED
+ printf("This program runs since %d seconds.\n", i++);
}
}