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.
Dependencies: mbed SDFileSystem
Revision 0:24db6536e52e, committed 2019-08-22
- Comitter:
- takepiyo
- Date:
- Thu Aug 22 09:04:44 2019 +0000
- Commit message:
- kanatutest0822
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Thu Aug 22 09:04:44 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/teams/mbed/code/SDFileSystem/#8db0d3b02cec
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/inletclose.h Thu Aug 22 09:04:44 2019 +0000
@@ -0,0 +1,53 @@
+#include "mbed.h"
+
+#ifndef InletClose_H
+#define InletClose_H
+
+class Inlet
+{
+private:
+DigitalOut _Out;//モータ用 1で回転,0で停止
+
+AnalogIn _In1;
+AnalogIn _In2;//感圧センサーとつなぐピン
+
+float value1;//感圧センサーの値をいれる
+float value2;
+
+public:
+
+ Inlet(PinName Out,PinName In1,PinName In2)
+ :_Out(Out),_In1(In1),_In2(In2){}
+
+
+ void Close(float judge)//センサのどっちかがjudgeを超えるとモーターは停止
+ {
+ _Out=1;
+
+ if(getvalue1()>judge | getvalue2()>judge)
+ {
+ _Out=0;
+ }
+ }
+
+ void Stop()
+ {
+ _Out=0;
+ }
+
+ float getvalue1()
+ {
+ value1=_In1.read();
+ return value1;
+ }
+
+ float getvalue2()
+ {
+ value2=_In2.read();
+ return value2;
+ }
+
+
+};
+
+#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Aug 22 09:04:44 2019 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "inletclose.h"
+#include "SDFileSystem.h"
+
+Inlet inlet(p26,p15,p16);
+
+Serial pc(USBTX,USBRX);
+
+SDFileSystem sd(p11, p12, p13, p14, "sd");
+FILE* fp;
+
+DigitalOut myled(LED1);
+DigitalOut myled2(LED2);
+
+int main()
+{
+ fp = fopen("/sd/Safety_Test/kanatu.csv", "a");
+ if(fp != NULL)
+ {
+ myled=1;
+ }
+ else
+ {
+ myled2=1;
+ fp = fopen("/sd/Safety_Test/kanatu.csv", "a");
+ wait(3);
+ myled2=0;
+ }
+
+
+ float time=0;
+
+ while(1)
+ {
+ inlet.Close(1.1);
+ pc.printf("%04.2f,%04.2f\n",inlet.getvalue1(),inlet.getvalue2());
+ fprintf(fp,"%.2f,%04.2f,%04.2f\n",time,inlet.getvalue1(),inlet.getvalue2());
+ wait(0.1);
+ time=time+0.1;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Aug 22 09:04:44 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/e1686b8d5b90 \ No newline at end of file