Hi, merry Xmas
I’ve previously posted a topic (https://forum.arduino.cc/index.php?topic=636117.0) but I have a more specific thread now.
I’m trying to use a proximity sensor (Omron E2EG-X5C2) to count motor cycles (maximum speed: 3600 rpm) and I’m using a optocoupler (6n136, for speed) and an Arduino Mega. This is not my area of expertise so it can be basic errors, maybe you guys can help me, both datasheet are attached. Attaching it to an interrupt is a next step, the problem now is that the value read from D2 keeps oscilating, as one can see on print from plotter serial (just a println(digitalRead(buttonPin)).
My scheme is attached too, I’ve placed some led to identify if sensor is working, both of them turn on when an object is near (LED 2 with more ligth than LED 1), as well as expected.
Searching on web I would guess it should be a basic grounding mistake, but as I said, I’m not much experienced on eletronics, so any opinion of yours will help.
Thank you very much,
6N136.pdf (609 KB)
E2EG-X5C2.pdf (221 KB)
Proximity_and_opto_25_dez_19.pdf (17 KB)
Monitor.ino (412 Bytes)