aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/audio_test/audio_test.pde59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/audio_test/audio_test.pde b/src/audio_test/audio_test.pde
new file mode 100644
index 0000000..bc01e20
--- /dev/null
+++ b/src/audio_test/audio_test.pde
@@ -0,0 +1,59 @@
+/*
+ * SQRLS Audio Test
+ */
+
+ int speakerOnePin = 5;
+ int speakerTwoPin = 6;
+ int motionSensorPin = 7;
+
+void setup() {
+
+ pinMode(motionSensorPin, INPUT);
+ pinMode(speakerOnePin, OUTPUT);
+ pinMode(speakerTwoPin, OUTPUT);
+
+ // Set pins 5&6 to a 62500Hz PWM clock
+ TCCR0B = TCCR0B & 0b11111000 | 0x01;
+}
+
+void loop() {
+
+ bark(random(50,100)^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));
+ }
+
+}
+
+void triangleWave(int len) {
+
+ for(int i = 0; i < len; i++) {
+ analogWrite(speakerOnePin, i*255/len);
+ }
+ for(int i = 0; i < len; i++) {
+ analogWrite(speakerOnePin, 255 - i*255/len);
+ }
+}
+
+void sawWave(int len) {
+ for(int i = 0; i < len; i++) {
+ analogWrite(speakerOnePin, i);
+ }
+}