Umemura Runa / Mbed 2 deprecated minirobo_honban

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
rumemura
Date:
Fri Oct 09 16:02:19 2020 +0000
Commit message:
ume_

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld 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	Fri Oct 09 16:02:19 2020 +0000
@@ -0,0 +1,86 @@
+#include "mbed.h"
+#include "string"
+
+RawSerial con(p28,p27,115200);
+RawSerial saber1(p13,p14,115200);
+RawSerial pc (USBTX,USBRX,115200);
+Ticker tras;
+string tras_str = "";
+string USBtx_str = "";
+
+DigitalOut Ben1(p23); // 電磁弁
+DigitalOut Ben2(p24); //電磁弁
+DigitalOut LSwitch(p26); //リミットスイッチ
+DigitalIn DS1(p28); //モーター
+DigitalIn DS2(p27); //モーター
+DigitalOut ledG(p17); //LEDgreen
+DigitalOut ledR(p20); //LEDred
+Ticker timer;
+
+int speed;
+int muki;
+
+char button;
+void atras()
+{
+    char con_c = con.getc();
+    tras_str += con_c;
+    if(con_c == '\n') {
+        USBtx_str = tras_str;
+        button = tras_str[0];
+        tras_str = "";
+    }
+}
+void aUSBtx()
+{
+    //con.printf("LPCtras41\n");
+    //pc.printf(USBtx_str.c_str());
+    pc.printf("%d\n",int(button));
+
+}
+int main()
+{
+    tras.attach(&aUSBtx,0.5);
+
+    con.attach(&atras,RawSerial::RxIrq);
+    while(1) {
+        if(button == 1) {
+            muki = 1;
+            speed = 100;
+
+            saber1.putc(132);
+            saber1.putc(muki);
+            saber1.putc(speed);
+            saber1.putc( ( 132 + muki + speed ) & 127 );
+        }
+        if(button == 2) {
+            muki = 0;
+            speed = 100;
+
+            saber1.putc(132);
+            saber1.putc(muki);
+            saber1.putc(speed);
+            saber1.putc( ( 132 + muki + speed ) & 127 );
+        }
+    }
+    if(button == 8) {
+        pc.printf("8!!!!!!!!!!!");
+    }
+
+
+    if(button == 4) {
+        Ben1 = 1;
+        ledR = 1;
+        wait(0.1);
+        pc.printf("4!!!!!!!!!!!");
+    }
+
+
+    if(button == 16) {
+        Ben2 = 1;
+        ledG = 1;
+        wait(0.1);
+        pc.printf("16!!!!!!!!!!!");
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 09 16:02:19 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file