1 / 5

robot whistle challenge

living with the lab. piezo speaker circuit. robot whistle challenge. © 2011 LWTL faculty team. living with the lab. wiring and simple programming. the sketch below will create a square wave with a frequency of approximately 2500 Hz . . . human hearing ranges from about 20Hz to 20,000 Hz.

delphina
Télécharger la présentation

robot whistle challenge

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. living with the lab piezo speaker circuit robot whistle challenge © 2011 LWTL faculty team

  2. living with the lab wiring and simple programming the sketch below will create a square wave with a frequency of approximately 2500 Hz . . . human hearing ranges from about 20Hz to 20,000 Hz digital output (pin 13) void setup() { pinMode(13,OUTPUT); } void loop() { int half_period=200; digitalWrite(13,HIGH); delayMicroseconds(half_period); digitalWrite(13,LOW); delayMicroseconds(half_period); }

  3. living with the lab whistling robot challenge With the piezo speaker installed on the breadboard of your robot, write a sketch to cause the speaker to make a whistle (the instructor will tell you what the whistle should sound like). Have the instructor check your whistle when you are satisfied with the sound. If you don’t finish during class, then complete this outside of class, and demonstrate your working program in class next time to the instructor. HINT:You may need to use several “for” loops where the pitch varies within the loops.

  4. living with the lab • example to get you going • The program shown uses a single, repeating “for” loop to create a sound similar to an alarm. • You can use this program as a starting point, but your whistle will sound best with several for loops. initial frequency: void setup() { pinMode(13,OUTPUT); } void loop() { for(int i=1500; i>500; i=i-8) { digitalWrite(13,HIGH); delayMicroseconds(i); digitalWrite(13,LOW); delayMicroseconds(i); } delay(150); } final frequency: 150 ms 150 ms 1000 frequency (Hz) 330 time (s)

  5. living with the lab delay frequency (Hz) your frequency vs. time plot may look more like this time (s)

More Related