在奈何老师的帮助下通过电位器可以实现了···
const int analogInPin = A0; // Analog input pin that the potentiometeris attached to const int analogOutPin = 9; // Analogoutput pin that the LED is attached to int sensorValue = 0; // value read from the pot int outputValue = 0; // value output to the PWM (analogout) void setup() { //initialize serial communications at 9600 bps: Serial.begin(9600); } void loop() { sensorValue = analogRead(analogInPin); outputValue = map(sensorValue, 0, 1023, 0, 255); analogWrite(analogOutPin, outputValue); delay(sensorValue); analogWrite(analogOutPin, 0); delay(sensorValue);
}
超声波模块反馈的是一个电平 ···
如何用超声波模块替换掉电位器实现呢???
|