error in my code.I can't understand the error.

The ( ) and { } must be used in pairs. If you use CTRL-T, or Tools:Autoformat, it will saying something like too many { or not enough }.
In this case, you're missing the } to close out this statement:

if ((val = HIGH) && (Old_val=LOW)) // (need == for these for a comparison test as pointed out already)
{
The missing } needs to go before the else.
Ah, I see you added that in this post.

and then it looks like you need another to close out loop().

And, analogWrite only works on the PWM pins - 3,5,6,9,10,11.
Pins 7 and 13 do not support 0 to 255 PWM levels with analogWrite.