一、
int sinputPin=10;/*Change according to the hardware configure*/
int soutputPin=8;/*Change according to the hardware configure*/
Int buzzPin=7;/*Change according to the hardware configure*/
int wait;
void setup()
{
//set the IO working mode pinMode(sinputPin,INPUT);
PinMode(soutputPin,OUTPUT);
PinMode(buzzPin,OUTPUT);
//Setup the serial port Serial.begin(9600);
}
void loop()
{
//the next 5 lines are used to generate a pulse
//to trig the ultrasonic ranging unit
digitalWrite(soutputPin,LOW);
delay(100);
digitalWrite(soutputPin,HIGHT);
delayMicroseconds(15);
digitalWrite(soutputPin,LOW);
//get response from the ranging unit
评论0