/* Mino Parts required: potentiometer speaker tiltsensor Created 22 July 2017 by Léa */ // variable to hold sensor value int sensorValue; int tiltPin = 7; // tiltsensor is connected to digital pin 7 int val; // variable to store the read value void setup() { pinMode(tiltPin,INPUT); // sets the pin as input } void loop() { //read the input and store it in a variable val = digitalRead(tiltPin); // read the input pin if (val==HIGH){ sensorValue = analogRead;// potentiometer is connected to analog pin 0 // map the sensor values to a wide range of pitches int pitch = map(sensorValue, 0, 1023, 500, 1200); // speaker is connected to digital pin 8 // play the tone for 250 ms tone(8, pitch, 250); // wait for a moment delay(350); } }