# RF Remote 遙控器發射端 -------------------------------------------------------- StartUp 當啟動時() sendZeroSet搖桿校正 Radio Group 廣播群組設為 = 1 -------------------------------------------------------- Forever 重複無限次() X1 Y1 = (x,y) buttonProc按鈕程序 -------------------------------------------------------- KEY D sendZeroSet搖桿校正 -------------------------------------------------------- buttonProc 按鈕程序() KEY 1 2 3 45670 -------------------------------------------------------- sendZeroSet 搖桿校正() X0 Y0 = (x,y) -------------------------------------------------------- # RF Car 機器人接收端 # Variables 變數定義 ---------------------------------------- KEY 0=未按下 1=A,2=B,..34567(按鍵) X0,Y0 類比搖桿初始位置值 X,Y 類比搖桿移動位置值 X=X1-X0,Y=Y1=Y0 speed = min(abs(Y)*2,1023) speed_L = speedFitRange(speed+(X*2)) speed_R = speedFitRange(speed-(X*2)) ---------------------------------------- # Status Flag 狀態旗標 flag_set_zero 類比搖桿是否有歸零 flag_update 是否有收到更新值 flag_run 馬達是否啟動 ----------------------------------------