void setup() {
  // put your setup code here, to run once:
pinMode(A1, INPUT);
pinMode(11, OUTPUT);
 Serial.begin(9600);
}
void loop() {
  // put your main code here, to run repeatedly:
    int sensorValue = analogRead(A1);
     float voltage = sensorValue * (5.0 / 1023.0);
if (voltage<=2)
{
  analogWrite(11, 150);
}
}
#define NOTE_G3  196
#define NOTE_C4  262
int signalPin =2;
int receivePin =3;
int val=0;
// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3
};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 4
};
void setup() {
  Serial.begin(9600);
  pinMode(signalPin, OUTPUT);
  pinMode(receivePin, INPUT);
  digitalWrite(signalPin, HIGH);
  
}
void loop() {
val = digitalRead (receivePin);
 Serial.println(val);
 if (val == HIGH){
  delay(0);
 }
 else{
{
 // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 2; thisNote++) {
    // to calculate the note duration, take one second
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000 / noteDurations[thisNote];
    tone(8, melody[thisNote], noteDuration);
    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);}
}
}
 }