int speaker = A1;
int ldr = A2;
int pot = A0;
int ldrm,potm;
 
void setup(){
  randomSeed(analogRead(5));  
  Serial.begin(9600);
}
 
void loop(){
  ldrm=analogRead(ldr);
  potm=analogRead(pot);
  if (ldrm<potm){
    tone(speaker,1000); 
  }
  if (ldrm>potm+5){
    noTone(speaker);
    delay(1000*random(30,90));  
  }
}
