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:fabee0295f0e
--- /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!!!!!!!!!!!");
+ }
+}
+