我的超声波距离传感器的数值一直为零
int R=13;
int B=12;
int G=11;
int zongkaiguan=10;
int valzong;
int juli;
int T=A0;//触发
int E=A1;//回响
int buzzer=9;
void loop()
{
valzong=digitalRead(zongkaiguan);
Serial.print("zongkaiguan: ");
if(valzong>0)
{
Serial.println("ON");
analogWrite(R,0);
analogWrite(B,0);
analogWrite(G,255);
digitalWrite(T,LOW);
delayMicroseconds(10);
digitalWrite(T,HIGH);
delayMicroseconds(10);
digitalWrite(T,LOW);
juli=pulseIn(E,HIGH)/58.0;
Serial.print("juli= ");
Serial.print(juli);
Serial.println(" cm");
delay(10);
if (juli<=15)
{
analogWrite(R,250);
analogWrite(B,10);
analogWrite(G,128);//在工作状态下,橙色灯亮
delay(2000);
}
else
{
for(int i=0;i<255;i++)
{analogWrite(buzzer,i);
delay(2);
}
for(int i=255;i>0;i--)
{analogWrite(buzzer,i);
delay(1);
}
}
}