開關控制 TTP223 觸控板模組
首先,藉由"亮生活 / Bright Side""簡單介紹觸控螢幕的運作原理"認識一下"觸控"
除了螢幕之外,大家生活上是不是常常看到其他類型的觸控應用
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
電路接法
TTP223觸控板是電容式的觸控板
所以只要接觸到會產生電流變化的物品(金屬物、產生靜電的物品)都有可能會有反應。
我們用Arduino開發版的A0腳位,來判斷觸控板是否有被觸碰。
找下方的方法接好(要注意VCC的位置不要接錯,接錯容易讓TTP223模組燒毀。)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
程式編輯
一樣開啟mBlock 來寫程式 (mBlock前期準備看這)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
在腳位方塊區找到"類比埠(A)0",因為插在A0的位置,所以數字就用"0"就好。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
程式範例(一)
讓舞台上的熊貓腳色說數字,看看觸控後會顯示多少
這裡會用到mBlock的即時功能,所以"設備"和"角色"兩個地方都要編寫
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
首先我們在角色的區域編輯程式方塊
拉出"當綠旗被點一下"
"不停重複"
"說'你好'"
並請建立一個變數"數值"
照下圖方式拚好
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
接著回到"設備"的欄位
拉出"當綠旗被點一下"
"不停重複"
"變數'數值'設為0"
"類比埠(A)0"
照下圖方式拚好
選"即時" ==> 連線 (若是之前有燒入程式,記得執行更新韌體)
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
連線成功後我們按下綠旗,觸碰TTP223模組,熊貓會出現一組數值
我們可以發現,遠離LED就不會亮,數值也會變0,接近時就會直接出現固定的數值(可能±1跳動),LED也會亮。
數字不會因為遠近而改變(若要改變就要改模組上的元件)
所以接下來寫程式時,只要判斷"類比埠(A)0"是否大於1,就可以當作是否有觸碰開關。
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
範例程式(二)
利用8X8的MAX7219模組,做一個送禮物的互動遊戲
MAX7219模組教學
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
首先會出現一個禮物盒的畫面,當觸控開關時就會轉而顯示另一個圖案或動畫。
有興趣的同學,可以進階設計嘗試用亂數顯示出隨機的圖案。
參考範例:互動應用 - 剪刀、石頭、布
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →