Specifications
| Type | Slotted optical switch with a comparator and an indicator LED. Something in the slot reads HIGH |
|---|---|
| Sensor | GK105A: an infrared LED and a phototransistor facing each other across the slot, in one 12.9 × 6.3 × 11 mm housing |
| Slot | 5 mm wide and 8 mm deep. The beam passes through windows drawn about 0.7 mm wide, below the top of the towers |
| Comparator | LM393 judging the light sensor against half of VCC, set by two 10 kΩ. No knob, and no hysteresis |
| SIGNAL | The comparator's open-collector output with a 10 kΩ pull-up to VCC. Clear: about 0.15 V, LOW. Blocked: VCC, HIGH. Read it with INPUT |
| Speed | About 1,900 pulses a second at most, from the sensor's typical 100 µs and 130 µs edges on its 10 kΩ: some 5,800 rpm on a 20-slot disc |
| Supply | Your board's logic voltage on VCC: 3V3 on an ESP32, ESP32-S3 or Pico, 5V on an Uno. SIGNAL is pulled up to it |
| Current | About 3 to 5 mA at 3.3 V and 5 to 8 mA at 5 V, worked out: the infrared LED is always on |
| Indicator | Red LED and 1 kΩ from VCC onto SIGNAL: lit while the slot is clear, dark while it is blocked. Not a power light |
| Pins to wire | 3 of the 4: GND, VCC and SIGNAL. NC is connected to nothing on the board |
| Header | 4-pin right-angle male, 2.54 mm pitch: GND, VCC, NC, SIGNAL, with GND on the square pad |
| Board | 22.4 × 30.4 mm, two 4.8 mm mounting holes 16 mm apart. The back prints TK61 INFRARED SPEED SENSOR and MEASURES SPEED VIA PULSES |
| In the box | 1 × TK61 block. It also ships inside the TinkerBlock kits |
What it does
It tells your board whether something is in its slot, fast enough to count the bars of a spinning disc. The two black towers are a GK105A: an infrared LED in the right-hand one, a light sensor in the left, and a 5 mm slot between them that the beam crosses. Anything opaque in the slot breaks the beam.
The light sensor does not drive SIGNAL itself. An LM393 comparator compares its voltage with half of VCC and answers: slot clear, SIGNAL LOW and the red LED lit; something in the slot, SIGNAL HIGH through a 10 kΩ pull-up and the LED dark. So HIGH means blocked. With a slotted disc on a shaft, every bar is one pulse, and pulses a second times 60 over the openings is rpm.
The page this replaces had the polarity right, but offered either supply as though it suited any board, and gave no speed limit. The block counts up to about 1,900 pulses a second, set by the light sensor, not the sketch.
Two things to know before wiring
- VCC is your board's logic voltage. SIGNAL is pulled up to VCC: 3V3 on an ESP32, an ESP32-S3 or a Pico, 5V on an Uno.
- Count on an interrupt. A loop that looks every few milliseconds misses
most of the pulses from a spinning disc.
attachInterrupton a rising edge catches every one.
Wiring, in four lines
- GND to your board's GND.
- VCC to 3V3 on an ESP32, ESP32-S3 or Pico; 5V on an Uno.
- SIGNAL to GPIO 4 on an ESP32-S3, GPIO 25 on an ESP32, D2 on an Uno, GP15 on a Pico.
- NC to nothing: it is connected to nothing on the board.
Then pinMode(pin, INPUT), and digitalRead(pin) is HIGH while something
blocks the slot.
Where to start
The handbook below is ten short articles, each with a working figure. The first read is the whole build in three wires and a few lines, and a tachometer counts a spinning disc in rpm.
For how it works, read a beam across a slot and the comparator and the light. If the count is off, when the count is wrong.
When it doesn’t work
- Does HIGH mean blocked or clear?
- Blocked. With the slot clear the comparator pulls SIGNAL LOW and the red LED lights; with something in the slot SIGNAL goes HIGH through the 10 kΩ pull-up and the LED goes dark.
- Should VCC go to 3V3 or 5V?
- To your board's logic voltage: 3V3 on an ESP32, ESP32-S3 or Pico, 5V on an Uno. SIGNAL is pulled up to VCC, so 5 V on VCC is 5 V on a 3.3 V pin every time something passes the slot.
- How do I get rpm from it?
- Put a disc with N openings on the shaft, its rim through the slot, and count rising edges on an interrupt for one second. rpm is the count times 60 over N. The handbook's tachometer does exactly that.
- How fast can it count?
- About 1,900 pulses a second, set by the light sensor's edges on its 10 kΩ; that is some 5,800 rpm on a 20-slot disc. Past it, the block starts to miss bars. Fewer openings bring the rate down.
- It counts two for one when I push a card in slowly.
- The comparator has no hysteresis, so a slow edge can flip SIGNAL more than once. Ignore a second edge within about half a millisecond, as the handbook's tachometer does, or longer for slow hand-driven counting.
- Does sunlight affect it?
- It can. The housing shields the sensor from most light, but the slot is open at the top and the ends, and sunlight carries a lot of infrared. Shade it if it misreads near a window.