thermin 2.0

 

#define piezoPin 9 //pin 9 with pitch control
#define lsr 0 //
#define fsr 5 //
#define minPitch 0x0FFF
#define maxPitch 0x01FF
 
void setup(){
  pinMode(piezoPin,OUTPUT);
  pinMode(lsr,INPUT);
  pinMode(fsr,INPUT);
  TCCR1A = 0x00; // sets timer control bits to PWM Phase and Frequency Correct mode
  TCCR1B = 0x12; // sets timer control bits to Prescaler N = 8
  analogWrite(piezoPin, 100); //something less than full volume
  Serial.begin(9600);
}
 
void loop(){
  //control the pitch
  ICR1 = map(analogRead(lsr), 30, 900, minPitch, maxPitch);
  delay(analogRead(fsr)/2); // control delay
}
0
Your rating: None