From 83f214211b042e93bd52e944f6481afdcd66470e Mon Sep 17 00:00:00 2001
From: Andrea Manni <andrea@piffa.net>
Date: Thu, 23 Apr 2015 14:40:43 +0200
Subject: [PATCH] piezo

---
 .../piezo_1_tonePitchFollower.ino             |  7 ++
 .../piezo_1_tonePitchFollower_ino.ino         | 64 -------------------
 .../piezo_3_toneMelody/piezo_3_toneMelody.ino |  5 ++
 3 files changed, 12 insertions(+), 64 deletions(-)
 delete mode 100644 piezo/piezo_1_tonePitchFollower/piezo_1_tonePitchFollower_ino/piezo_1_tonePitchFollower_ino.ino

diff --git a/piezo/piezo_1_tonePitchFollower/piezo_1_tonePitchFollower.ino b/piezo/piezo_1_tonePitchFollower/piezo_1_tonePitchFollower.ino
index e74c7b3..5ae3099 100644
--- a/piezo/piezo_1_tonePitchFollower/piezo_1_tonePitchFollower.ino
+++ b/piezo/piezo_1_tonePitchFollower/piezo_1_tonePitchFollower.ino
@@ -40,8 +40,15 @@ void loop() {
   delay(1);        // delay in between reads for stability
 }
 
+/* Domande:
+1. Modificare l'estensione del range di frequenza del piezo
+tra i valori 20hz e 20.000hz.
 
+2. Modificare lo script in modo che vengano emessi suoni solo quando
+una mano offusca leggermente la luce (il piezo non deve suonare
+se non c'e' un operatore a interagire con la fotoresistenza).
 
+*/
 
 
 
diff --git a/piezo/piezo_1_tonePitchFollower/piezo_1_tonePitchFollower_ino/piezo_1_tonePitchFollower_ino.ino b/piezo/piezo_1_tonePitchFollower/piezo_1_tonePitchFollower_ino/piezo_1_tonePitchFollower_ino.ino
deleted file mode 100644
index b5e9d24..0000000
--- a/piezo/piezo_1_tonePitchFollower/piezo_1_tonePitchFollower_ino/piezo_1_tonePitchFollower_ino.ino
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Pitch following
-
-The input from a photo resistor dictates the pitch of a piezo.
-
- 
- */
-
-// These constants won't change:
-const int sensorPin = A0;    // pin that the sensor is attached to
-const int ledPin = 9;        // pin that the LED is attached to
-int thisPitch ;
-
-// calibration variables:
-int sensorValue = 0;         // the sensor value
-int sensorMin = 1023;        // minimum sensor value
-int sensorMax = 0;           // maximum sensor value
-
-
-void setup() {
-  // turn on LED to signal the start of the calibration period:
-  pinMode(13, OUTPUT);
-  digitalWrite(13, HIGH);
-
-  // calibrate during the first five seconds 
-  while (millis() < 5000) {
-    sensorValue = analogRead(sensorPin);
-
-    // record the maximum sensor value
-    if (sensorValue > sensorMax) {
-      sensorMax = sensorValue;
-    }
-
-    // record the minimum sensor value
-    if (sensorValue < sensorMin) {
-      sensorMin = sensorValue;
-    }
-  }
-
-  // signal the end of the calibration period
-  digitalWrite(13, LOW);
-}
-
-void loop() {
-  // read the sensor:
-  sensorValue = analogRead(sensorPin);
-
-  // apply the calibration to the sensor reading
-  thisPitch = map(sensorValue, sensorMin, sensorMax, 120, 1500);
-  // map the analog input range (in this case, min - max from the photoresistor)
-  // to the output pitch range (120 - 1500Hz)
-  // change the minimum and maximum input numbers below
-  // depending on the range your sensor's giving:
-  
-  // in case the sensor value is outside the range seen during calibration
-  thisPitch = constrain(sensorValue, 120, 1500);
-
-
-  
-  // play the pitch:
-  tone(ledPin, thisPitch, 10); // Tone is built in function
-  delay(1);        // delay in between notes
-}
-
diff --git a/piezo/piezo_3_toneMelody/piezo_3_toneMelody.ino b/piezo/piezo_3_toneMelody/piezo_3_toneMelody.ino
index a5c5701..c4435d2 100644
--- a/piezo/piezo_3_toneMelody/piezo_3_toneMelody.ino
+++ b/piezo/piezo_3_toneMelody/piezo_3_toneMelody.ino
@@ -52,4 +52,9 @@ void loop() {
 
 /* Domande
 1. Codificare Twinkle twinkle little star
+2. Modificare lo script pitch follower (fotoresistenza + piezo) 
+   per suonare una serie di beep durante la fase di calibrazione
+   e un breve motivetto (magari una scala crescente) per confermare
+   l'avvenuta calibrazione.
+3. Codificare (magari utilizzando dei loop) qualche suono di allarme / conferma.
 */
-- 
2.39.2