How to interface Ir sensor with arduino mega 2560?
What is the function of SCL pin i arduino mega 2560?

Which IR sensor ? (link to datsheet necessary).

SCL is the I2C clock signal.

There is as such no specific ir sensor ,but it has transmitter and receiver ,and it is used to calculate the no. rotation that the wheel makes

If you want to be supported - just think about you have posted so far.
We need at least some more information about:

  • what are you planning to do?
  • what are the electrical components (actors/sensors) which are to be connected to the arduino?


  • you want to calculate the rotation speed of a turning wheel, right?

Then we need to know:

  • how do you want to measure it? - markers on the wheel (black/white) ?
  • what speed (RPM) range are we in (min..max)?

First code available?

No there is a small circular shaft with cuts at every small intervals..and yes iwant to calculate the Rotation of the the wheel using ir sensor

code is not available

Do you have an idea

  1. how many cuts are in that shaft?
  2. about the range (min..max) the RPM will be in?

First information will be needed to have a divisor for the calculation of RPM. If your IR sensor detects 40 pulses and you have 20 cuts on the shaft, it has detected 40/20*60 = 120 RPM.

Second information gives an idea upfront how fast the IR has to be not missing any pulses.

Did you already buy a IR device?
For this project you need one that is able to send IR to the turning shaft and detects the reflected IR light coming from either the cuts or the plain shaft - hopefully it can distinguish them clearly. If not then you have to mount something on the shaft which gives better reflection.

But let's suppose it will work without modification.
Then you have to consider how close you have to mount the IR sensor to the shaft, so it operates in the best sensitive distance (hopefully you can adjust the sensitivity on your device in the needed distance range).

Last but not least you need code -> did you ever tried the search function in this forum?
If you look for "IR sensor RPM" you will get a lot of hits. Just do some homework to learn a bit more about what you are going to do and come back with your personal approach and you will be helped to get to the next level.