void setup() { pinMode(11,OUTPUT); // on pinMode(10,INPUT); // mas de 500 pinMode(9,INPUT); // mas de 750 } void loop() { // read the sensor: // int sensorValue = analogRead(A1); int sensorValue = analogRead(A0); if (sensorValue < 100) { digitalWrite(11, HIGH); digitalWrite(10, HIGH); digitalWrite(9, HIGH); } else if (sensorValue > 300) { digitalWrite(11, HIGH); digitalWrite(10, LOW); digitalWrite(9, HIGH); } else { digitalWrite(11, HIGH); digitalWrite(10, HIGH); digitalWrite(9, LOW); } // print the sensor reading so you know its range // map the analog input range (in this case, 400 - 1000 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: int thisPitch = map(sensorValue, 0, 1023, 200, 6000); //int thisPitch = map(sensorValue, 100, 600, 200, 2000); // play the pitch: tone(3, thisPitch, 1000); // tone(3, 440, 1000); delay(100); // delay in between reads for stability }