If possible you should always post code directly in the forum thread as text using code tags (</> button on the toolbar). This will make it easy for anyone to look at it, which will increase the likelihood of you getting help. If the sketch is longer than the forum will allow then it's ok to add it as an attachment but in this case it's a short sketch so there's absolutely no reason to use an attachment.
Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you're using the Arduino Web Editor then you will not have access to this useful tool. I recommend using the standard Arduino IDE instead.
Please remove unnecessary blank lines from your code before posting to the forum. One or two to separate code into logical sections is fine but large spaces for no reason or random blank lines just make for more scrolling when we're trying to read your code.
TraianGrg:
so what is wrong?
Why don't you tell us? Is is not compiling? If so, then post the full error message. Is it not working as expected? If so, then explain exactly what you intend the code to do and what it's doing instead.