arduino laser projector project - rpm meter prob


I am trying to build an arduino laser projector.

at first it will be with 1 mirror , rotating , and rpm meter (optical) using interrupt 0 , and laser powered by uln2003

code , debug info , pics are here -

but my code (based on something I downloaded from arduino site) gives me strange rpm's!

can you help?



Hello tomas, nice project.

Try removing the serial output from the interrupt handler. You could create an array to hold your data (just a second or so, say 100 elements),store the data in the handler and send them from your loop when your array gets full. Don't forget to disable interrupts when you read and send the data and enable them when you are done. If this solves your problem then you can design some code to makes sure that the interrupt handler and serial print routines don't interfere with each other.

I created the debug lines in the interrupt handler to debug the error...

it's still there when I remove those lines...

I will try to delete all serial print code and see what happens.


Hi there, great project - I plan to try something similar myself when I've finished my current project.

I would try to slim down the interrupt handler as far as possible and move debugging code into your main loop. Also, from your photos it looks like the arm (cardboard?) cutting the phototransistor may not be balanced - it will interact / drag when it nears the rpm counter aperture. I would recommend trying a circular disc with one or two small holes cut into it, and triggering your interupt on a rising signal from your phototransistor - this should be more stable.

Also, is there a chance that the interrupt is double-triggering? I don't know enough yet about how the ATMega processor works (I'm an Arduino newbie) but you could try disabling interrups at the start of your handler then re-enabling after logging your timecode, and possibly using a 'debounce' type circuit on the output from your phototransistor to ensure it gives a clean logic signal.

Just ideas, but hope they help. Let us know how you get on.

  1. will try using a circular disc with a small slit (maybe the cardboard arm is really too wide)

  2. will try connecting the transistor to ocsilloscope to see what it looks like. maybe upload the image

  3. as you can see on the link from my page , the 15-year-old kids who did this with an atmega8 (not arduino) used a similiar sensor and arm , so there should be litle difference.