#coding utf-8
import serial
import re

def main():
    with serial.Serial('/dev/cu.HC-06-DevB-1', 9600, timeout=1) as ser:
        while True:
            c = ser.readline()
            d = re.findall('[0-9]+\.+[0-9]',str(c),flags=0)
            d = [float(i) for i in d]
            for i in range(0, len(d)):  #要素を1つずつ順番に出力します
                print(d[i])
        ser.close()

if __name__=="__main__":
    main()


@@ -18,130 +18,767 @@
 ort 
-serial%0Aimport re%0A%0Adef main():%0A    with serial.Serial('/dev/cu.HC-06-DevB-1', 9600, timeout=1) as ser:%0A        while True:%0A
+numpy as np%0Aimport serial%0Aimport re%0A%0Aclass LoverDuck(object):%0A%0A    def __init__(self):%0A        self.t = 0%0A        self.last_move_t = 0%0A        self.LIMIT_TIME = 10000 #ms%0A        self.MOVE_THRESHOLD = 1000%0A        self.get_base_value()%0A%0A    def get_base_value(self):%0A        %22%22%22%E5%AE%9F%E9%A8%93%E7%9A%84%E3%81%AB%E5%BE%97%E3%81%9F%E5%80%A4%E3%82%92%E4%BD%BF%E7%94%A8%0A        %22%22%22%0A        # %E6%B0%B4%E4%B8%8A%0A        self.base_x = -2737%0A        self.base_y = -3970%0A        self.base_z = 13934%0A        # %E9%99%B8%E4%B8%8A(debug%E7%94%A8)%0A        self.base_x = 256%0A        self.base_y = 1088%0A        self.base_z = 14592%0A%0A    def connect_ble(self):%0A        %22%22%2210ms%E3%81%94%E3%81%A8%E3%81%AB%E5%8F%97%E4%BF%A1%0A        %22%22%22%0A        with serial.Serial('/dev/cu.HC-06-DevB-1', 9600, timeout=1) as ser:%0A            print(%22Start connected!%22)%0A            while True:%0A                # %E6%99%82%E9%96%93update%0A                self.t += 10%0A    
     
@@ -804,16 +804,20 @@
 dline()%0A
+    
         
@@ -880,17 +880,27 @@
         
+   
-d
+ x, y, z
  = %5Bfloa
@@ -932,135 +932,743 @@
     
-for i in range(0, len(d)):  #%E8%A6%81%E7%B4%A0%E3%82%921%E3%81%A4%E3%81%9A%E3%81%A4%E9%A0%86%E7%95%AA%E3%81%AB%E5%87%BA%E5%8A%9B%E3%81%97%E3%81%BE%E3%81%99%0A                print(d%5Bi%5D)%0A        ser.close()%0A%0Aif __name__==%22__main__%22:%0A    main
+    print(%22x:%22, x, %22y: %22,y, %22z: %22,z)%0A                if self.__judge_if_move(x, y, z):%0A                    print(%22Detect Movement%22)%0A                    self.last_move_t = self.t%0A                else:%0A                    pass%0A                if self.t - self.last_move_t %3E self.LIMIT_TIME:%0A                    print(%22No Detection%22)%0A            ser.close()%0A%0A    def __judge_if_move(self, x, y, z):%0A        %22%22%22XYZ%E5%85%A8%E6%96%B9%E5%90%91%E3%81%A7%E9%96%BE%E5%80%A4%E3%82%92%E8%B6%85%E3%81%88%E3%81%A6%E3%81%84%E3%81%9F%E3%82%89%E5%8B%95%E3%81%8D%E3%81%A8%E8%AA%8D%E8%AD%98%0A        %22%22%22%0A        if np.abs(x-self.base_x) %3E self.MOVE_THRESHOLD and np.abs(y-self.base_y) %3E self.MOVE_THRESHOLD and np.abs(z-self.base_z) %3E self.MOVE_THRESHOLD:%0A            return True%0A        else:%0A            return False%0A%0Aif __name__==%22__main__%22:%0A    loverduck = LoverDuck()%0A    loverduck.connect_ble
 ()%0A%0A

Add detect function