Interfacing Digital Infrared Sensor with BBFuino and SK28A

1.0 Introduction

 Digital Infrared Sensor (SN-E18-B03N1)

The SN-E18-B03N1 contains infrared sensor for use as reflection of IR signal barriers. It uses special sensor to detect the modulated  IR signal reflected back from a nearby either or a far distance of the object. The transmitter and the receiver between the light intensity of the digital infrared sensor can change into for the purpose of current changes in order to achieve the detection.

The output pin is pull up to the power pin due to the internally pull high of the sensor. Hence the module will output a HIGH if no object is detected and a LOW if  an object is detected.

Refer here for more information about Digital Infrared Sensor.

In this tutorial, you are going to learn on how to use the BBFuino and SK28A to read signal from SN-E18-B03N1.

 

2.0 Requirement

2.1 Hardware

                                                              

      1 x BBFuino                                        1 x SK28A                                              1 x SN-E18-B03N1

                                           

      1 x LCD (8×2)                                   1 x Breadboard                                        1 x UC00A Rev2.0

               

1 x Power adapter DC 12V        1 x 10k ohm resistor and jumper   1 x  2×8 header pin(Female)

                        

      1 x 2×8 header pin(Male)               1 x UIC-A                                          1 x UIC00B

1 x 3 pin terminal block

 

2.2 Software

Arduino Ide software for BBFuino can be download from here

USB driver for UC00A, can be download form here

 

3.0 Methodologies

3.1 SN-E18-B03N1 with BBFuino

1. A cutter used to cut the 2×40 header pin (Male) into 2×8 ways. The pins was soldered to the 2×8 LCD as shown below.

                                                

                                         Before (Front view)                      After (Back view)

                                                 Figure 1: Soldering the header pins onto the 2×8 LCD

2. A 2×40 header pins (Female) was cutting into 2×8 ways and being soldered onto the LCD pad (DS3) of BBFuino board as shown below.

                                                      

                                              Front view                                        Back view

                                                 Figure 2: Soldering the header pin onto the BBFuino Board

3. Soldered the JP8 on the BBFuino as shown below in order the LCD backlight can be function properly.

                                                        

                                            Before                                                   After

                                                   Figure 3: Soldering the JP8 on the BBFuino board

4. The 2×8 LCD with 2×8 ways of header pin was plug in into the BBFuino board and fit them to a breadboard as shown below.

 

              Figure 4: 2×8 LCD plug to the BBFuino board and fit them to a breadboard

5. Connect the circuit as the schematic provided.

 

               a) Schematic of connection between SN-E18-B03N1 and the microcontroller

             b) Circuit connection using Fritzing

   c) Actual Circuit connection

  Figure 5: Schematic and circuit connection of the SN-E18-B03N1 with BBFuino

*Note: The SN-E18-B03N1 user manual can be download from here

 

6. Connect the UC00A Rev 2.0 to the programming pins of BBFuino board in the correct way and other end to the computer as shown below:

                                    

                                          Figure 6: Connection between BBfuino board and the UC00A Rev 2.0

 

7. Open Arduino IDE, choose suitable type of Arduino board (for BBFuino, choose Arduino Uno) and the connected COM port (which can be checked through Device Manager ) as shown below:              

 

   a) Choose the type of Arduino board                                  b) Choose the connected COM port 

                                        Figure 7: Choose the type of Arduino board and the connected COM port

 

8. Start to write the codes.

Write the function which the LCD will display ‘Block!’ when SN-E18-B03N1 detect object in front of it and LCD display ‘Unblock.’ as  it does not detect anything in font of it within 30cm.

The sample source code is shown as below:

#include <LiquidCrystal.h> //include the header file for LCD

LiquidCrystal lcd (8, 9, 4, 5, 6, 7);

const int Digitalpin = 12;

int pinstate;

void setup()

{   

   lcd.begin(16, 2);   

   lcd.clear();   

   lcd.setCursor(0, 0);   

  pinMode (Digitalpin, INPUT);

}

void loop()

{   

   pinstate = digitalRead(Digitalpin);   

   if(pinstate == HIGH)  

  {     

      lcd.print(“Block! “);   

   }   

  else   

  {     

      lcd.print(“Unblock.”);   

   }      

 lcd.setCursor(0, 0);

}

*The sample source code can be downloaded form the attachment.

9. Compile the code and load to the device.

 

     a) Click on the icon to compile the code           b) click on the icon to load the code to device

                                             Figure 8: Compiling and load the code

 

10. Once the code has been successfully loaded to the device, the result will be as below:

 

                      a) Show ‘Block!’ as detect a block in font of it

                   b) Show ‘Unblock.’ as detect no block in front of it

                                                             Figure 9: Result

 

3.2 SN-E18-B03N1 with SK28A

1. Repeat the step from 1 to 5 as the above (section 3.1).

                         a) Circuit connection using Fritzing

*The microcontroller used for this example is PIC16F876A

                                                         b) Actual circuit connection

                                                      Figure 10: Circuit connection

 

2. Connect the UIC-A and UIC00B with the SK28A.

     

                  Figure 11: Connection between UIC-A and UIC00B with the LCD

 

3. Open the MPLAB X IDE and create a new project.

* You can refer to here for creating a new project by using MPlab X IDE.

4. Enter the code and compile the code by using the MPlab XC8 compiler.

Write the function which the LCD will display ‘Block!’ when SN-E18-B03N1 detect object in front of it and LCD display ‘Unblock.’ as  it does not detect anything in font of it within 30cm.

One part of the sample source code shown as below.

 

 

*The sample source code can be downloaded from the attachment.

5. Build the code and load it to the device.

6. The result shown as below.

                             a) Show ‘Block!’ as detect a block in font of it 

                b) Show ‘Unblock.’ as detect no block in front of it

                                                    Figure 12: Result

 

* Please post your inquiry/feedback/comments in our technical forum if you have 🙂

Attachment

1.  BBFuino_SN-E18-B03N1

2.  SK28A_SN-E18-B03N1

Buy

, , , ,

Related Post

Getting Started with Colour Sensor Module (SN-COLOUR-MOD)

Getting Started with Tilt Sensor (SN-TILT)

Getting Started with Vibration Sensor Module (Normally Off) (SN-VIBRATE-MOD)

Getting Started with IR Distance Click

6 thoughts on “Interfacing Digital Infrared Sensor with BBFuino and SK28A

  1. Hello there.. I was trying sample code for this tutorial. It works perfectly. I have a doubt as I refer to the statement ” The output pin is pull up to the power pin due to the internally pull high of the sensor. Hence the module will output a HIGH if no object is detected and a LOW if an object is detected. “.

    To my understanding, if HIGH means there is no object (unblock) and LOW means there is object (block). In the sample code

    pinstate = digitalRead(Digitalpin);
    if(pinstate == HIGH)
    {
    lcd.print(“Block! “);
    }
    else
    {
    lcd.print(“Unblock.”);
    }

    Maybe you need to correct the sample code. Correct me if I’m correct. I’m learning too.

  2. SN-GP2D120XJ00F is analog while SN-E18-B03N1 is digital, you need to modify the code the get analog voltage and convert it to distance.

Leave a Reply

Your email address will not be published. Required fields are marked *