XinaBox SL06 - Gesture (APDS-9960) 教學

SL06 的用途包括 : Gesture detection (手勢感應), Proximity detection (近接感應), Digital Ambient Light Sense (ALS) (環境光感測) and Color Sense (RGBC) (顏色感應).
所需用料 :
micro:bit x 1
micro:bit bridge IM01 x 1
Gesture (APDS-9960) Sensor (SL06) x1
xChips Connector x 1
usb cable x 1
micro:bit coding platform : https://makecode.microbit.org/
編程教學 :


2. 在 SL06的 Mode 拖拉出 「SL06 enable ______ mode」到工作台上。

3. 把它加至 on start 下 , 然後選取我們需用到的mode
這次我們先以 LIGHT MODE 進行教學
注意 : 每次只能啟動1個mode
LIGHT MODE CODING 教學 :
Illuminance 部份 :

把 SL06 illuminance LUX 拖拉至工作台 , 目的是利用這個code來量度光度。

由於 LUX 是一個數字 , 我們需要利用 show number 來顯示 LUX ,
至於選用 on button A pressed 的原因則是方便我們作記錄。
RGB 編程部份 :

Light Mode 還具備 color detection 的功用 , 可以分辨出 紅(R) , 綠(G) 跟 藍 (B) RGB 3種顏色。
原理是透過測量 R,G,B 這3種顏色在光線中反射至 SL06 sensor 的數量 ,
例如 : 將紅光投射至SL06 sensor , SL06 red light 的數值便會最高 , 其他側會很低 ,
從而推斷出投射的光線是紅光。

利用不同 Button 去測試不同顏色 , 從而測試出光源是那種顏色。
PROXIMITY MODE 編程教學 :

首先把 MODE 轉成 PROXIMITY ,
PROXIMITY 是一個近距探測sensor , 可以量度距離 , range 為 0 - 255 。

愈接近 SL06 , Proximity 的數據愈大 , 愈遠則愈小

然後在SL06中取出「SL06 proximity」。

把它放到 on button A pressed 內 , 由於 proximity 是數值 , 所以需用 show number 作顯示。
Gesture 編程教學 :

首先把 MODE 轉成 Gesture, Gesture MODE 可以探測手勢

把 SL06 read gesture 加到 forever 下 , 從而命令SL06不斷探測gesture(手勢)。

把 SL06 on gesture LEFT 拉至工作台 , 然後將 show leds 加到裡面 ,
把 leds 塗成左箭嘴的圖示以顯示現在GESTURE是「左面」。
也可以利用其他output以顯示gesture , 例如 : show string " left "

多加一個 SL06 on gesture , 然後把它改成 on 「 RIGHT」或並他方向以作測試。

跟 GESTURE on LEFT 一樣 , on RIGHT 的 show leds 塗成向右箭嘴。
GESTURE 不逐一說明 , 煩請自行測試其他的 GESTURE。
測試 :

當手向左移動時 , micro:bit 的 LED 會顯示向左的箭嘴 , 代表 GESTURE on LEFT ,
向右移動時剛會出現向右箭嘴。
注意 : 手需在 SL06 sensor 上移動才能感應到手的GESTURE/movement。