I am trying to figure out how to make an owl screeching sound for my project.
here is my current code.
tone(buzzer,1700);
delay(100);
tone(buzzer,1800);
delay(1000);
noTone(buzzer);
delay(100);
I am trying to figure out how to make an owl screeching sound for my project.
here is my current code.
tone(buzzer,1700);
delay(100);
tone(buzzer,1800);
delay(1000);
noTone(buzzer);
delay(100);
Does it sound like an owl screeching?
Can you please post a good description of a possible problem. I don't see one except for the fact that your code will not compile because it's incomplete; e.g. setup() and loop() are missing.
Your problem does not indicate a problem with IDE 1.x and therefore has been moved to a more suitable location on the forum.
No, that's why I am asking for your help on how to make it an owl screeching.
This is just a part of my code.
this is my full code
#include <Servo.h>
const int buzzer = 4; //buzzer to arduino pin 9
Servo myservo;
int pos = 0;
void setup() {
myservo.attach(3);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
{digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(1000);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
delay(1000);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(1000);
}
for (pos = 0; pos <= 180; pos += 1) {
myservo.write(pos);
delay(55); }
{
***tone(buzzer,1700);***
*** delay(100);***
*** tone(buzzer,1800);***
*** delay(1000);***
*** noTone(buzzer);***
*** delay(100);***
{digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(100);
digitalWrite(7,LOW);
digitalWrite(8,LOW);
delay(100);
digitalWrite(7,HIGH);
digitalWrite(8,HIGH);
delay(100);
}
}
for (pos = 180; pos >= 0; pos -= 1) {
myservo.write(pos);
delay(55); }
{
***tone(buzzer, 1700);***
*** delay(100);***
*** tone(buzzer, 1800); ***
*** delay(1000);***
*** noTone(buzzer);***
*** delay(100);***
}
}
Consider a mini MP3 player, playing back a recorded owl screech. Hard to beat for $9.
For added effect, add screeches from hawks, eagles, etc.
Could you guys think of a tone for the peizo.
if you listen you'll see there is not only one frequency...
may be you'll be better off with an animated scarecrow ![]()
Some snippets of code that create chirps:
const int speakerPin=A2;
const int piezopin=A2;
void highChirp(int intensity, int chirpsNumber){
int i;
int x;
for(int veces=0; veces<=chirpsNumber; veces++){
for (i=100; i>0; i--)
{
for (x=0; x<intensity; x++)
{
digitalWrite (piezopin,HIGH);
delayMicroseconds (i);
digitalWrite (piezopin,LOW);
delayMicroseconds (i);
}
}
}
}
void lowChirp(int intensity, int chirpsNumber){
int i;
int x;
for(int veces=0; veces<=chirpsNumber; veces++){
for (i=300; i<500; i++)
{
digitalWrite (piezopin,HIGH);
delayMicroseconds(i);
digitalWrite(piezopin,LOW);
delayMicroseconds(i);
}
for (i=190; i>180; i--)
{
for ( x=0; x<5; x++)
{
digitalWrite (piezopin,HIGH);
delayMicroseconds (i);
digitalWrite (piezopin,LOW);
delayMicroseconds (i);
}
}
}
}
//Chirp function
//adapted from Michael Still's 'Cricket Noise Door Bell' arduino project
//http://www.stillhq.com/svn/trunk/arduino/DoorBellWithMatt/DoorBellWithMatt.pde
//We need to pass in a desired chirp length using an integer or our predefined
//constants
void chirp(int length){
for(int i = 0; i < length; i += 2)
{
delay(i);
digitalWrite(speakerPin, LOW);
delay(length - i);
digitalWrite(speakerPin, HIGH);
}
}
void chirp2(void) {
int i,p,n;
char per;
DDRC |= (1<<2);
for (n=230; n>120; n--) { //bird chirp us(per*4)
// for (n=230; n<250; n++) { //cricket chirp
per=240-n;
p = n/32; //number of pulses
for (i=0; i<p; i++) {
PINC |= (1<<2);
delayMicroseconds(per*4); //toggle buzzer pin
}
}
}
void setup() {
while(1) {
chirp2();
delay(3000);
}
}
void loop() {}
What are all those '***' ? Obviously fails to compile as it stands. Were you trying to format bold?
+1 for using DFR Player.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.