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:2735404d7d5d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Apr 01 16:06:16 2017 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+void led_switch(void);
+Ticker time_up;
+DigitalOut myled(LED_GREEN);
+Serial sim(D9,D7);
+Serial usb(USBTX,USBRX);
+char rx_buffer[256];
+int rx_in;
+void flushBuffer() {
+ for(int i=0; i<256; i++){
+ usb.printf("%c", rx_buffer[i]);
+ rx_buffer[i]=0;
+ }
+ rx_in=0;
+ }
+void led_switch() {
+ myled=!myled;
+ while(sim.readable()) {
+ char c = sim.getc();
+ rx_buffer[rx_in] = c;
+ rx_in++;
+ if(rx_in==256)
+ rx_in=0;
+ }
+ return;
+}
+
+int main(){
+ myled=1;
+ usb.printf("1\n");
+ time_up.attach(&led_switch, 0.5);
+ while(true) {
+ flushBuffer();
+
+ sim.printf("AT\r\n");
+ //wait(3);
+ usb.printf("//%s//",rx_buffer);
+
+ wait(1);
+ }
+}
+
\ No newline at end of file