Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double
- t, dist;
- void setup(){
- pinMode(3,OUTPUT);
- pinMode(4, INPUT);
- Serial.begin(9600);
- }
- void loop(){
- digitalWrite(3, LOW);
- delayMicroseconds(2);
- digitalWrite(3, HIGH);
- delayMicroseconds(10);
- digitalWrite(3, LOW);
- t = pulseIn(4, HIGH);
- if (t>1000) t=1000;
- Serial.println(t);
- tone(9, 4000, 100);
- delay(t/2);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement