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:c3d61e6fda16
diff -r 000000000000 -r c3d61e6fda16 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri May 05 19:44:26 2017 +0000
@@ -0,0 +1,72 @@
+#include "mbed.h"
+
+//------------------------------------
+// Hyperterminal configuration
+// 9600 bauds, 8-bit data, no parity
+//------------------------------------
+
+RawSerial pc(USBTX,USBRX,9600);
+
+DigitalOut led_green(LED1);
+DigitalOut led_red(LED2);
+
+//DigitalIn led_green_in(LED1);
+
+InterruptIn user_button(USER_BUTTON);
+
+float delay_on = 0.2;
+float delay_off = 1.0;
+
+void button_pressed()
+{
+ delay_on = 0.1;
+ delay_off = 0.1;
+}
+
+void button_released()
+{
+ delay_on = 0.2;
+ delay_off = 1.0;
+}
+
+int main()
+{
+ user_button.rise(&button_pressed);
+ user_button.fall(&button_released);
+
+ //pc.format(8, Serial::None, 1);
+
+ //pc.baud(9600);
+
+ bool flag=false;
+
+ while(1) {
+
+ //pc.printf("This program runs since %d seconds.\r\n", i);
+
+
+ //wait(1);
+
+ if (pc.readable()){
+ char c =pc.getc ();
+ //pc.putc(c);
+ if (c == 's')flag = true;
+ if (c == 'r')flag = false;
+ if (c == 't')flag=!flag;
+ led_green =flag;
+
+ }
+
+
+
+
+ /*
+ for(char a = 'a';a<='z';a++){
+ pc.putc(a);
+ pc.putc('\r');
+ pc.putc('\n');
+ wait(0.1);
+ }
+ */
+ }
+}