Kirja   |  Artikkelit   |  Keskustelu   |  Tiedostot   |  Galleria
Hyönteisrobotti, kampanja.

Parallax PING Ultrasound sensor ja Piezon piippari yhdessä, testattu ja toimii

Toteutettu Parallax PING Ultrasound sensor yhdistetty Piezon piippariin siten että piippari aloittaa antamaan äänimerkkiä kohteen ollessa lähempänä kuin 20cm.

 int speakerPin = 9;
 unsigned long echo = 0;
 int ultraSoundSignal = 8; // Ultrasound signal pin
 unsigned long ultrasoundValue = 0;

 void setup()
 {
 Serial.begin(9600);
 pinMode(ultraSoundSignal,OUTPUT);
 pinMode(speakerPin, OUTPUT);
 }

 unsigned long ping(){
 pinMode(ultraSoundSignal, OUTPUT); // Switch signalpin to output
 digitalWrite(ultraSoundSignal, LOW); // Send low pulse
 delayMicroseconds(2); // Wait for 2 microseconds
 digitalWrite(ultraSoundSignal, HIGH); // Send high pulse
 delayMicroseconds(5); // Wait for 5 microseconds
 digitalWrite(ultraSoundSignal, LOW); // Holdoff
 pinMode(ultraSoundSignal, INPUT); // Switch signalpin to input
 digitalWrite(ultraSoundSignal, HIGH); // Turn on pullup resistor
  echo = pulseIn(ultraSoundSignal, HIGH); //Listen for echo
  ultrasoundValue = (echo / 58.138); //convert to CM
 return ultrasoundValue;
 }

 void loop()
 {
 int x = 0;
 x = ping();
 Serial.print(x);
 Serial.println(" cm");
 delay(250); //delay 1/4 seconds.
 if (x<=20)
   {
     digitalWrite(speakerPin, HIGH); delayMicroseconds(1000);
     digitalWrite(speakerPin, LOW); delayMicroseconds(10);
   }
 }
  |     |     |     |     |     |  

The basic theory behind the

The basic theory behind the ParKontroller is the Sound Navigation and Ranging (SONAR) technique that is used for finding the distance and direction of a remote object underwater by transmitting sound waves and detecting reflections from it. First, a series of short ultrasonic pulses are transmitted using a transducer that changes voltage into sound waves. The transmitted pulse is reflected off an object, and the reflected wave is then received by another transducer that converts sound waves into voltage. The transmitted signal is also known as the ‘ping’ and the received signal is known as the ‘pong’

220-702 - 352-001 - 640-553

(Round corners at the bottom)