tel. 24910 23755 / fax 24910 26620

 

/*
Theremin like music organ to play sounds it
will change the pitch of the note as you wave
your hand in front of it
*/
// constants won't change. They're used here to
// set pin numbers:
// in Pin 12 we will connect the piezo speaker.
// Give it a name.
const int speakerPin = 12;
// in Pin 0 we will connect the photocell.
// Give it a name.
const int photocellPin = 0;
// the setup routine runs once when you press
// reset:
void setup() {
}
// the loop routine runs over and over again
// forever:
void loop() {
  int reading = analogRead(photocellPin);
  int pitch = 200 + reading / 4;
  tone(speakerPin, pitch);
}

Κατηγορίες: Arduino

Social media & sharing icons powered by UltimatelySocial