const int button1 = 8;
const int P1Led = 11;
const int speaker = 10;
int makeSound = 0;
int light = 0;
void setup() {
pinMode(P1Led, OUTPUT);
pinMode(speaker, OUTPUT);
pinMode(button1, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
if (digitalRead(button1) == 0)
{
lightUp(P1Led);
digitalWrite(P1Led,LOW);
}
}
void lightUp(int light)
{
while (digitalRead(button1) == 0)
{
analogWrite(light, 255);
tone(10,200,1000);
delay(1000);
}
button1 == 1;
}