aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/audio_test/audio_test.pde62
1 files changed, 44 insertions, 18 deletions
diff --git a/src/audio_test/audio_test.pde b/src/audio_test/audio_test.pde
index bc01e20..a33d580 100644
--- a/src/audio_test/audio_test.pde
+++ b/src/audio_test/audio_test.pde
@@ -2,46 +2,71 @@
* SQRLS Audio Test
*/
- int speakerOnePin = 5;
- int speakerTwoPin = 6;
- int motionSensorPin = 7;
+int speakerOnePin = 5;
+int speakerTwoPin = 6;
+int volumePin = 9;
+int motionSensorPin = 7;
+int b = 0;
+int bb = 0;
void setup() {
pinMode(motionSensorPin, INPUT);
pinMode(speakerOnePin, OUTPUT);
pinMode(speakerTwoPin, OUTPUT);
-
+ pinMode(volumePin, OUTPUT);
// Set pins 5&6 to a 62500Hz PWM clock
TCCR0B = TCCR0B & 0b11111000 | 0x01;
+ TCCR1B = TCCR1B & 0b11111000 | 0x01;
+
}
-void loop() {
-
- bark(random(50,100)^2/100);
-
- delay(random(50000,200000)^2/100000);
+void loop(){
+ //THIS IS THE ACTUAL LOOP OF THE SQUIRREL APPARATUS
+ //barker(random(3));
+ analogWrite(volumePin,12);
}
+// Caw sound. eg,
+// caw(1000);
+// delay(200000);
+void caw(int ll) {
+ for(int j=1800; j<1900; j+=1000/ll) {
+ if(j<1816){
+ analogWrite(volumePin,(j-1815)*4/5+12);
+ }
+ if(j>1875){
+ analogWrite(volumePin,(1875-j)/4+12);
+ }
+ b++;
+ if (b==10){
+ bb=1;
+ b=0;
+ }
+ sawWave(j/8+500*bb+random(10));
+ bb=0;
+ }
+}
+
+// Bark sound. eg,
+// barker(random(3));
+void barker(int num) {
+ for(int u=0;u<num;u++){
+ bark(random(50,80)^2/100);
+ delay(random(50000,200000)^2/100000);
+ }
+}
void bark(int ll) {
- /*
- for(float j=300; j>0; j-=20) {
- //if(random(5) == 1) {
- // delayMicroseconds(100);
- //}
- triangleWave(j*j/300);
- }
- */
-
for(int j=500; j>200; j-=3000/ll) {
sawWave(j+random(50));
}
}
+// Generic triangle wave sound
void triangleWave(int len) {
for(int i = 0; i < len; i++) {
@@ -52,6 +77,7 @@ void triangleWave(int len) {
}
}
+// Generic saw wave sound
void sawWave(int len) {
for(int i = 0; i < len; i++) {
analogWrite(speakerOnePin, i);