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.
Diff: main.cpp
- Revision:
- 0:55150494d6db
- Child:
- 1:83391eec9fef
diff -r 000000000000 -r 55150494d6db main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Aug 10 00:05:27 2015 +0000
@@ -0,0 +1,67 @@
+#include "mbed.h"
+
+DigitalOut led_red(LED_RED);
+DigitalOut led_green(LED_GREEN);
+DigitalOut led_blue(LED_BLUE);
+DigitalIn sw2(SW2);
+DigitalIn sw3(SW3);
+Serial pc(USBTX, USBRX);
+
+int check_sw2(int choice)
+{
+ if(sw2 == 0)
+ {
+ pc.printf("SW2 button pressed. \n");
+ switch(choice)
+ {
+ case 0:
+ led_red = 0;
+ led_green = 1;
+ break;
+ case 1:
+ led_red = 1;
+ led_green = 0;
+ break;
+ case 2:
+ led_red = 0;
+ led_green = 0;
+ break;
+ case 3:
+ led_red = 1;
+ led_green = 1;
+ break;
+ }
+ choice++;
+ if(choice > 3) choice = 0;
+ }
+ return choice;
+}
+
+void check_sw3(DigitalOut led_status)
+{
+ if(sw3 == 0)
+ {
+ pc.printf("SW3 button pressed. \n");
+ if(led_status) led_blue = 0;
+ else led_blue = 1;
+ }
+}
+
+int main()
+{
+ int choice = 0;
+
+ led_green = 1;
+ led_red = 1;
+ led_blue = 1;
+
+ pc.baud(115200);
+ pc.printf("Hello World from FRDM-K64F board.\n");
+
+ while(true)
+ {
+ choice = check_sw2(choice);
+ check_sw3(led_blue);
+ wait(0.3);
+ }
+}