//当做普通IO脚, 输出 50us高电平后再拉低. pinMode(pin, OUTPUT); digitalWrite(pin, HIGH); delayMicroseconds(50); // send a 50 us pulse to get the current position digitalWrite(pin, LOW);
//置成输入, 读取ADC值转换为角度信息. pinMode(pin, INPUT); int position = pulseIn(pin, HIGH); //e.g. 500-2500