讀取 Futaba 2.4G 接收機 Channel 信號..

Channel 4 (Rudder) "美國手"

Code:

unsigned long TransmitterThrottle=0;
unsigned long TransmitterCH4=0;

void setup()
{
Serial.begin(9600);

pinMode ( 9, INPUT);
pinMode (10, INPUT);

clearLCD();
}

void CheckTransmitter()
{
TransmitterThrottle = (pulseIn (9, HIGH, 200000))/10;
TransmitterCH4 = (pulseIn (10, HIGH, 200000));
}

void loop()
{
CheckTransmitter();

clearLCD (); // 清除 LCD 畫面
Serial.print ("pulse= ");
Serial.print (TransmitterThrottle, DEC);

Serial.print (" CH4: ");
Serial.print (TransmitterCH4, DEC );

delay(100);
}
// ===== clear the LCD =====
void clearLCD()
{
Serial.print(12, BYTE);
}

輸出數值:
中立: 1509 ~ 1514
至左: 1381 ~ 1388
至右: 1633 ~ 1639
要先搞清楚這些數值的 跳動 原因 ...

~ 待續 ~

沒有留言:

張貼留言