Merging 3 sketches NOOB ALERT!

PaulMurrayCbr:
Replace val with

byte micVal =0;

byte pirVal =0;
byte tempVal =0;




and adjust the placed where val gets used to use the appropriate variable.

I thought I had already advised the OP to do that sort of thing.

...R