实际上这些引脚的意义都能查到 。
但很多都忽视了具体的接线:
VH VW VL 三个都要接!VL接GND VH VW作为电阻两端测试
void setup() {
// put your setup code here, to run once:
pinMode(4, OUTPUT); //CS
pinMode(5, OUTPUT); //NC
pinMode(6, OUTPUT); //UD
pinMode(12,INPUT_PULLUP);
digitalWrite(4, LOW);
digitalWrite(6, LOW);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int sensorVal = digitalRead(12);
Serial.println(sensorVal);
if (sensorVal!=HIGH){
digitalWrite(5, LOW);
} else{
digitalWrite(5, HIGH);
}
}
测试即可