elementary serial print using the external IO breakout board and PL2303
main.cpp@1:c180896f50ce, 2019-10-18 (annotated)
- Committer:
- matrixmike
- Date:
- Fri Oct 18 08:22:34 2019 +0000
- Revision:
- 1:c180896f50ce
- Parent:
- 0:782954b320bb
- Child:
- 2:b3fbc276081a
testing features of the slim version of printf
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
matrixmike | 0:782954b320bb | 1 | /* |
matrixmike | 0:782954b320bb | 2 | The MIT License (MIT) |
matrixmike | 0:782954b320bb | 3 | |
matrixmike | 0:782954b320bb | 4 | Copyright (c) 2016 British Broadcasting Corporation. |
matrixmike | 0:782954b320bb | 5 | This software is provided by Lancaster University by arrangement with the BBC. |
matrixmike | 0:782954b320bb | 6 | |
matrixmike | 0:782954b320bb | 7 | Permission is hereby granted, free of charge, to any person obtaining a |
matrixmike | 0:782954b320bb | 8 | copy of this software and associated documentation files (the "Software"), |
matrixmike | 0:782954b320bb | 9 | to deal in the Software without restriction, including without limitation |
matrixmike | 0:782954b320bb | 10 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
matrixmike | 0:782954b320bb | 11 | and/or sell copies of the Software, and to permit persons to whom the |
matrixmike | 0:782954b320bb | 12 | Software is furnished to do so, subject to the following conditions: |
matrixmike | 0:782954b320bb | 13 | |
matrixmike | 0:782954b320bb | 14 | The above copyright notice and this permission notice shall be included in |
matrixmike | 0:782954b320bb | 15 | all copies or substantial portions of the Software. |
matrixmike | 0:782954b320bb | 16 | |
matrixmike | 0:782954b320bb | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
matrixmike | 0:782954b320bb | 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
matrixmike | 0:782954b320bb | 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
matrixmike | 0:782954b320bb | 20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
matrixmike | 0:782954b320bb | 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
matrixmike | 0:782954b320bb | 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
matrixmike | 0:782954b320bb | 23 | DEALINGS IN THE SOFTWARE. |
matrixmike | 0:782954b320bb | 24 | */ |
matrixmike | 0:782954b320bb | 25 | |
matrixmike | 0:782954b320bb | 26 | #include "MicroBit.h" |
matrixmike | 0:782954b320bb | 27 | #include "mbed.h" |
matrixmike | 0:782954b320bb | 28 | |
matrixmike | 0:782954b320bb | 29 | Serial pc(USBTX, USBRX); |
matrixmike | 0:782954b320bb | 30 | MicroBit uBit; |
matrixmike | 0:782954b320bb | 31 | |
matrixmike | 0:782954b320bb | 32 | int main() |
matrixmike | 0:782954b320bb | 33 | { |
matrixmike | 0:782954b320bb | 34 | // Initialise the micro:bit runtime. |
matrixmike | 0:782954b320bb | 35 | uBit.init(); |
matrixmike | 0:782954b320bb | 36 | for ( int x = 2; x < 14; x++) { |
matrixmike | 0:782954b320bb | 37 | pc.printf("Hello World on a Friday\n\r"); |
matrixmike | 1:c180896f50ce | 38 | pc.printf("Hello World on a %d Friday\n\r", x ); |
matrixmike | 1:c180896f50ce | 39 | pc.printf("Hello World on a %c Friday\n\r", '%' ); |
matrixmike | 0:782954b320bb | 40 | // Insert your code here! |
matrixmike | 0:782954b320bb | 41 | } |
matrixmike | 0:782954b320bb | 42 | uBit.display.scroll("HELLO WORLD! :)"); |
matrixmike | 0:782954b320bb | 43 | |
matrixmike | 0:782954b320bb | 44 | // If main exits, there may still be other fibers running or registered event handlers etc. |
matrixmike | 0:782954b320bb | 45 | // Simply release this fiber, which will mean we enter the scheduler. Worse case, we then |
matrixmike | 0:782954b320bb | 46 | // sit in the idle task forever, in a power efficient sleep. |
matrixmike | 0:782954b320bb | 47 | release_fiber(); |
matrixmike | 0:782954b320bb | 48 | } |
matrixmike | 0:782954b320bb | 49 | // Print "Hello World" to the PC |
matrixmike | 0:782954b320bb | 50 | /* |
matrixmike | 0:782954b320bb | 51 | #include "mbed.h" |
matrixmike | 0:782954b320bb | 52 | |
matrixmike | 0:782954b320bb | 53 | Serial pc(USBTX, USBRX); |
matrixmike | 0:782954b320bb | 54 | |
matrixmike | 0:782954b320bb | 55 | int main() { |
matrixmike | 0:782954b320bb | 56 | pc.printf("Hello World\n"); |
matrixmike | 0:782954b320bb | 57 | } |
matrixmike | 0:782954b320bb | 58 | */ |