void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(16,OUTPUT);
pinMode(2,OUTPUT);
pinMode(12,INPUT);
}
void loop() {
int slide = digitalRead(12);
if(slide == 1){
digitalWrite(16,HIGH);
tone(2,1200);
}
else
{
digitalWrite(16,LOW);
noTone(2);
}
// put your main code here, to run repeatedly:
delay(100); // this speeds up the simulation
}