Photoelectric wheel encoder IR sensor module

  • Photoelectric wheel encoder IR sensor module
  • Product Code: SEN0105
  • Reward Points: 2
  • Available in stock
  • $3.05

  • Ex Tax: $2.75
  • Price in reward points: 275

Proximity & Rangers

Photoelectric wheel encoder IR sensor module

Dimension:23mmx20mmx20mm
Chip: LM393, on the radio infrared head
Working voltage: DC 5 V

Features & Applications:
  1. Single-channel output.
  2. Active Low Output.
  3. Sensitivity is not adjustable.
  4. It can be used for counting objects
  5. Can be used to measure motor RPM as an encoder (Example below)

NOTE: If used with Arduino interrupt, it is advised to supply 3.3 VDC to the sensor's VCC pin to acquire proper pulses counts.

#define SENSOR_PIN 2
#define DIR_PIN 4
#define PWM_PIN 5
#define PPR 40  //20 * 2 (on change)
volatile long encCount = 0;
long lastEncCount = 0;
bool currentDir = true;
int currentPwm = 0;
double currentRPM = 0;
long pm = 0;
void setup() 
{
  Serial.begin(115200);
  
  pinMode(DIR_PIN, OUTPUT);
  pinMode(PWM_PIN, OUTPUT);
  pinMode(SENSOR_PIN, INPUT_PULLUP);
  attachInterrupt(0, enc_isr, CHANGE);
  analogWrite(PWM_PIN, 0);
}
void enc_isr()
{
  if(currentDir) encCount++;
  else encCount--;
}
void loop() 
{
  long tnow = millis();
  
  if(tnow - pm >= 250)
  {
    pm = tnow;
    currentRPM = double(encCount - lastEncCount);  
    lastEncCount = encCount;
    currentRPM = currentRPM * 4.0 * 60.0;
    currentRPM = currentRPM / double(PPR);
    
    Serial.println(currentRPM);
  }
  if(Serial.available())
  {
    char c = Serial.read();
    if(c == '+')
      currentPwm += 10;
    else if(c == '-')
      currentPwm -= 10;
    else if(c == '0')
      currentPwm = 0;
    if(currentPwm > 255) currentPwm = 255;
    if(currentPwm < -255) currentPwm = -255;
  }
  digitalWrite(DIR_PIN, currentPwm >= 0);
  analogWrite(PWM_PIN, abs(currentPwm));
}

Write a review

Note: HTML is not translated!
    Bad           Good

Related Products

Shiftout LED Kit

Shiftout LED Kit

This shiftout LED Kit  includes a very simple and small LED display module. It makes it possible for you to directly connect many 7-segment led modules in a chain. So you coul..

$14.54

Digital Tilt Sensor

Digital Tilt Sensor

This is a digital tilt switch. It  can be used as a simple tilt sensor.  Simple plug to our IO/Sensor Expansion board, you can make amazing interactive projects. Spe..

$3.39

Brushless DC Motor with Encoder 12V 159RPM - Built in Driver

Brushless DC Motor with Encoder 12V 159RPM - Built in Driver

This is a motor revolution: a new DC brushless motor with built-in motor driver. It can be conncected to Arduino directly without external motor driver. Whatsmore, the motor comes ..

$34.35

Motor Mount Holder Bracket Fasteners for RC

Motor Mount Holder Bracket Fasteners for RC

Motor Mount Holder Bracket Fasteners for RC•  Material: rigid aluminum alloy•  Length: 22.5mm•  Width: 15.5mm•  Thickness: 5mm•  With 2 set 3*30 and 2pcs 3..

$2.05

3 in1 Plant Soil PH Tester Moisture Light Meter

3 in1 Plant Soil PH Tester Moisture Light Meter

3 in1 Plant Soil PH Tester Moisture Light MeterFeatures:3 functions in one compact meter-measure the moisture and pH content of the soil and the environmental light.  Sci..

$11.10 $15.60

HOT

Tags: photoelectric, wheel, encoder, sensor, module, sensors