描述
技術規格
1.訊號傳輸型式: 類比 (Analog)
2.壽命:500000 次以上
3.運轉角度:60∘+-5∘
4.模組尺寸:40 x 30 mm
5.電壓範圍: 5.0V
商品內容
§ 搖桿模組 1個
§ RJ11 6P4C 25cm 信號線 1條
程式範例
在此範例配合S4A Sensor Board 做簡單實驗。
const int analogInPin1 = A3; // 搖桿接到 S4A Sensor Board A3/A4 孔位
const int analogInPin2 = A4; // 搖桿接到 S4A Sensor Board A3/A4 孔位
const int analogOutPin1 = 10; // D10 LED is attached
const int analogOutPin2 = 11; // D11 LED is attached
int sensorValue1 = 0; // X軸讀到數值
int outputValue1 = 0; // 輸出到LED數值
int sensorValue2 = 0; // Y軸讀到數值
int outputValue2 = 0; // 輸出到LED數值
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
}
void loop() {
// read the analog in value:
sensorValue1 = analogRead(analogInPin1);
sensorValue2 = analogRead(analogInPin2);
// map it to the range of the analog out:
outputValue1 = map(sensorValue1, 0, 1023, 0, 255);
outputValue2 = map(sensorValue2, 0, 1023, 0, 255);
// change the analog out value:
analogWrite(analogOutPin1, outputValue1);
analogWrite(analogOutPin2, outputValue2);
// print the results to the serial monitor:
Serial.print(“X = ” );
Serial.print(sensorValue1);
Serial.print(” outputX = “);
Serial.println(outputValue1);
Serial.print(“Y = ” );
Serial.print(sensorValue2);
Serial.print(” outputY = “);
Serial.println(outputValue2);
delay(500);
}
接線範例
接線方式如果搭配S4A Sensor Board只要把電話接頭(RJ11)接到標示A3A4孔位即可完成連接。