You can place your code between the code tags. Use the '#' button (above the smileys when you are writing a message).
You can also copy an URL in the text, like this:
http://arduino.cc/en/Reference/pulseInMy first thought was to measure the number of pulses during a certain time, but measuring the pulse length is a smart idea. You get the speed immediate for every rotation of the wheel. If it is accurate enough ...
But I think that the diameter of the wheel does not influence the pulse length.
But I have many questions:
- If your sketch is not working, so what is not working ? Please be more precise.
- How is the magnetic switch connected to the arduino ? can you upload a schematic ?
- Is the magnetic switch some kind of reed contact, and not some fancy hall sensor ?
- You checked the inputs ? are you sure the magnetic switch is working ?
- Can you turn the led on and off with code ?
- Is the variable 'time' chaning if you rotate the wheel with different speeds ?