Measuring RPM of gearbox using QRD114

I am trying to build a circuit that can measure the gear box RPM using a QRD114 and a reflector wheel. The actual circuit is attached along with a circuit diagram. I ultimately want to control the gearbox to move at certain intervals, and measure RPM.

The anode connected to the 240 ohm resistor to the op amp.

I can’t get it to show me the RPM of the reflector wheel.


int sensor = 0;

volatile long timeStoreA;
volatile long timeStoreB;
double stall = 100;

void setup(){
pinMode(sensor, INPUT);

timeStoreA = 0;
timeStoreB = 0;

void loop(){
long deltaT = abs(timeStoreA - timeStoreB);
analogWrite(gearbox, 90);
long revs = deltaT*6.;
long RPM = 60./revs * 1000000.;

I haven't looked at the code yet but that circuit looks waaaaay complicated to my inexperienced eye. What's wrong with the collector from the sensor going straight into the Arduino, pulled high with the internal pullups.

What do you recommend?

anm313: What do you recommend?

Just as I said.... but I'm no expert. I wouldn't call that a recommendation as such: there may be parts of this I'm not clued up on.

Collector high with a pullup, and then it goes low when the led's on.

You don't show how your sensor is actually wired, just its signal. Is it a plain unmounted sensor?- some are on boards and already "condition" the output with a pullup on the board and the led's series resistor built in.

Unmounted I think

So take the collector high with a pullup resistor (easiest is to use the INPUT_PULLUP) and then connect the collector to your Arduino i/o pin, like I said some days ago.

edit.... as shown here but you don't need that 5v connection and resistor if you use the internal pullup.

Connect the sensor to interrupt, then calculate amount of interrupts per second.

Interrupt? Just the MOSFET or do you you mean the entire circuit including the op-amps?