-16%

10mm槽寬 LM393 光電對射式計數感測器模組 | 馬達測速 | 紅外線遮斷開關 | 附 Arduino 範例

NT$48 NT$40 未稅

此款 槽型光耦模組 (亦稱光遮斷器模組 / Photo Interrupter) 擁有 10mm 寬度槽口,基於 LM393 比較器設計,提供穩定的數位開關量 (DO) 輸出。工作電壓為 5V,邏輯簡單易用:當物體遮擋槽口時輸出高電平 (LED 滅),無遮擋時輸出低電平 (LED 亮)。非常適合用於 馬達測速 (碼盤計數)、流水線計數紅外線遮斷開關 或自製機械極限開關,完全相容 Arduino 與各類微控制器開發。

尚有庫存

貨號: 75645613(B4-11) 分類: 標籤: , , ,
  • 詳細資訊

商品說明

Slotted LM393 Beam Infrared Light Counter Photoelectric Sensor Module

產品參數

  • PCB兩圓孔(點到點中心的距離)為 1.5cm,孔徑為0.3cm
  • 槽型光耦槽寬10mm
  • 主要晶片:LM393、槽型光耦H2010
  • 工作電壓:直流5伏

 

產品特點:

  • 具有信號輸出指示。
  • 單路信號輸出。
  • 有遮擋物時輸出高電平(LED燈滅),無遮擋物時輸出低電平(LED燈亮)
  • 靈敏度不可調。
  • 可用於工件計數、電機測速。。。。
  • 電路板輸出開關量!

LM393 光電對射式計數感測器模組 硬體介紹

範例碼

int encoder_pin = 2; // The pin the encoder is connected 
unsigned int rpm; // rpm reading
volatile byte pulses; // number of pulses
unsigned long timeold; 
// The number of pulses per revolution
// depends on your index disc!!
unsigned int pulsesperturn = 20;

 void counter()
 {
 //Update count
 pulses++; 
 }

void setup()
 {
 Serial.begin(9600);
 //Use statusPin to flash along with interrupts
 pinMode(encoder_pin, INPUT);
 
 //Interrupt 0 is digital pin 2, so that is where the IR detector is connected
 //Triggers on FALLING (change from HIGH to LOW)
 attachInterrupt(0, counter, FALLING);
 // Initialize
 pulses = 0;
 rpm = 0;
 timeold = 0;

 }

 void loop()
 {
 if (millis() - timeold >= 1000){ /*Uptade every one second, this will be equal to reading frecuency (Hz).*/
 
 //Don't process interrupts during calculations
 detachInterrupt(0);
 //Note that this would be 60*1000/(millis() - timeold)*pulses if the interrupt
 //happened once per revolution
 rpm = (60 * 1000 / pulsesperturn )/ (millis() - timeold)* pulses;
 timeold = millis();
 pulses = 0;
 
 //Write it out to serial port
 Serial.print("RPM = ");
 Serial.println(rpm,DEC);
 //Restart the interrupt processing
 attachInterrupt(0, counter, FALLING);
 }
 }