Project 8 Is the light blocked

1.Introduction

If you have seen a production line, you must be wondering how the machines do the workpiece counting. Well, in this lesson, we will show you how this technology is achieved.

2.Hardware required

  • EASY plug controller Board x1

  • USB cable x1

  • EASY plug cable x2

  • EASY plug Piranha LED Module x1

  • EASY plug Photo Interrupter Module x1

In realizing the counting process, below is a critical part called Photo Interrupter Module.

Upright part of this sensor is an infrared emitter and on the other side, it’s a shielded infrared detector. By emitting a beam of infrared light from one end to another end, the sensor can detect an object when it passes through the beam. It is used for many applications including optical limit switches, pellet dispensing, general object detection, etc. Below are its specifications:

  • Supply Voltage: 3.3V to 5V

  • Interface: Digital

  • Size: 38x20mm

3.Connection Diagram

Now, connect the LED module to the D10 port of the controller board and Photo Interrupter Module to D3 port using the EASY plug cables.

4.Sample Code

Connect the board to your PC using the USB cable; copy below code into Arduino IDE, and click upload to upload it to your board.

// photo interrupter module
 
int Led = 10 ;// define LED Interface
int buttonpin = 3; // define the photo interrupter sensor interface
int val ;// define numeric variables val

void setup ()
{
  pinMode (Led, OUTPUT) ;// define LED as output interface
  pinMode (buttonpin, INPUT) ;// define the photo interrupter sensor output interface   
}

void loop ()
{
  val = digitalRead (buttonpin) ;// digital interface will be assigned a value of 3 to read val
  if (val == HIGH) // When the light sensor detects a signal is interrupted, LED flashes
  {
    digitalWrite (Led, HIGH);
  }
  else
  {
    digitalWrite (Led, LOW);
  }
}

5.Result

After the above are done, the LED on the module will be on and the piranha LED will be off; place a paper card between the two ends of the module, you can see the LED on the module is off, and the piranha will be on. Now, you have a clear idea of how piece counting is done.