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 frdm_helloworld by
Revision 0:4f3ac9922229, committed 2014-04-03
- Comitter:
- Kojto
- Date:
- Thu Apr 03 08:36:21 2014 +0000
- Child:
- 1:e105199c1521
- Commit message:
- initial version of complete lab 1
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Apr 03 08:36:21 2014 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+
+DigitalOut led_red(LED_RED);
+DigitalOut led_green(LED_GREEN);
+DigitalIn sw2(SW2);
+DigitalIn sw3(SW3);
+Serial pc(USBTX, USBRX);
+
+void check_sw2(void)
+{
+ if (sw2 == 0) {
+ pc.printf("SW2 button pressed. \n");
+ led_red = 0;
+ led_green = 1;
+ }
+}
+
+void check_sw3(void)
+{
+ if (sw3 == 0) {
+ pc.printf("SW3 button pressed. \n");
+ led_green = 0;
+ led_red = 1;
+ pc.printf("5 characters will be echoed. Start typing. \n");
+ for (uint32_t i = 0; i < 5; i++) {
+ pc.putc(pc.getc());
+ }
+ pc.putc(13); /* CR */
+ pc.putc(10); /* LF */
+ }
+}
+
+int main() {
+ led_green = 1;
+ led_red = 1;
+ pc.baud(115200);
+ pc.printf("Hello World from FRDM-K64F board.\n");
+
+ while (true) {
+ check_sw2();
+ check_sw3();
+ wait(0.3);
+ }
+}
