Put 2 codes together! (School project)

kjetilmarstein:
Yes i have tried that. But i think this while loop from the wifi does that the clap would not be detected if i put it in the same loop as clapper loop..

WiFiClient client = server.available();
if (!client) {
return;
}
while (!client.available()) {
delay(1);
}
rest.handle(client);

While you are handling a client request, you won't be listening to clapping. Therefore, you need to make your client handling function as fast as possible, so that you don't miss too many claps.

It would probably be better to use two Arduinos - one as the server and one as the clapper. The clapper Arduino can tell the server Arduino that the lights should be off or on in a variety of ways.