Will this program work?

Firstly, what is the analogueWrite() controlling.

Secondly, if you enter the while loop with y < 255 you will never exit. The program will hang in the loop.

Thirdly, if you are reading AC you will have trouble, you'll have to rectify and smooth the voltage.

So the short answer is no, it won't work.


Rob