robostep8th / Mbed OS sw_test
Revision:
0:768dd398f2b8
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Dec 05 09:47:06 2020 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+
+int main()
+{
+    int a=0x40, b=0x80, c=0xc0, d=0x00; // a一行目0100=4, b二行目1000=8, c三行目1100=c, dはfield 0000=0
+    DigitalIn sw1_1(PC_5);
+    DigitalIn sw1_2(PA_12);
+    DigitalIn sw1_3(PA_11);
+    a=a+sw1_1.read() * 100+  sw1_2.read() * 10 +  sw1_3.read();
+
+    DigitalIn sw2_1(PB_12);
+    DigitalIn sw2_2(PB_11);
+    DigitalIn sw2_3(PB_2);
+    DigitalIn sw2_4(PB_1);
+
+    DigitalIn sw3_1(PB_15);
+    DigitalIn sw3_2(PB_14);
+    DigitalIn sw3_3(PB_13);
+
+    DigitalIn sw_field(PC_4);
+//ここまでは、ピンの設定
+
+    sw1_1.mode(PullUp);
+    sw1_2.mode(PullUp);
+    sw1_3.mode(PullUp);
+
+
+    sw2_1.mode(PullUp);
+    sw2_2.mode(PullUp);
+    sw2_3.mode(PullUp);
+    sw2_4.mode(PullUp);
+
+    sw3_1.mode(PullUp);
+    sw3_2.mode(PullUp);
+    sw3_3.mode(PullUp);
+
+    sw_field.mode(PullUp);
+//ここまでは、ピンのモード
+
+    a=a+sw1_1.read() * 100+  sw1_2.read() * 10 +  sw1_3.read();
+    b=b+sw2_1.read() * 1000+  sw2_2.read() * 100 +  sw2_3.read()*10 + sw2_4.read();
+    c=c+sw3_1.read() * 100+  sw3_2.read() * 10 +  sw3_3.read();
+    d=d+sw_field.read();
+
+    printf("%x\r\n", a);
+    printf("%x\r\n", b);
+    printf("%x\r\n", c);
+    printf("%x\r\n", d);