-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grilo.ino
40 lines (33 loc) · 818 Bytes
/
Grilo.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const int speakerPin = 5;
//const int sensorPin = 0;
const int highChirp = 20;
const int lowChirp = 14;
const int chirpCycle = 70;
const int chirpPause = 8;
const int numChirps = 10;
const int midChirp = 150;
const int skittish = 5000;
void setup() {
pinMode(speakerPin, OUTPUT);
//pinMode(sensorPin, INPUT);
}
void chirp() {
for (int i=1; i<=numChirps; i++) {
for (int j=1; j<=highChirp; j++) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(chirpCycle * 10);
digitalWrite(speakerPin, LOW);
delayMicroseconds(1000-(chirpCycle * 10));
}
digitalWrite(speakerPin, LOW);
if (i==numChirps/2) delay(midChirp);
else delay(lowChirp);
}
if ((random(chirpPause)) == 1) delay(random(200,1000));
else delay(midChirp);
}
void loop() {
//while(analogRead(sensorPin) <= 64) {
chirp();
//}
}