optical sensor

Hello,

I have an optical sensor and i connected it to pin 31 (Digital) in the arduino Mega 2560

but the code does not work
can anyone check my code which is attached here.
thanks in advance

best regards

A screenshot? Please read the stickies on how to post code. If you post the code in code tags, people can cut and paste the code into their IDE to help you troubleshoot the code.

Does not work is not a very good description of your problem. Describe what the code does and what you need the code to do.

I can't view the file on my device so others may not be able to, either.

I think I see two issues with your highlighted line (I am used to PIC processors which use a bit different syntax) - the first problem (I think) shouldn't "if (31, HIGH);" be "if digitalread(31) == HIGH" ? The second problem I see is the semicolon at the end of the if statement - that says that is the end of the expression so it ends there instead of the following code.