Using the KY-032 infrared sensor and a remote control with Micro:bit

Micro:bit 03-07-23
976 0

Tutorial plan

1- Introducing the KY-032 Infrared Sensor

2- The relationship between the KY-032 infrared sensor and a remote control

3- How to receive the Micro:bit board an infrared signal from the remote control using the KY-032 sensor?

4- The components needed to use the KY-032 infrared sensor with the Micro:bit board

5- Mounting the Micro:bit board with the KY-032 infrared sensor

6- Makecode programming of the Micro:bit board to receive data from the KY-032 infrared sensor

Introducing the KY-032 Infrared Sensor

The KY-032 Infrared Sensor is a module that is commonly used in electronics and robotics projects for detecting the presence of infrared signals. It is also known as an infrared obstacle avoidance sensor module. The module consists of an infrared emitter (LED) and an infrared receiver (phototransistor) placed side by side.

Here are some key features and characteristics of the KY-032 Infrared Sensor:

1- Detection Method: The sensor module detects infrared light by emitting a modulated infrared signal and measuring the reflection. When an object is present in front of the module, the infrared light emitted by the LED bounces off the object and is detected by the phototransistor.

2- Operating Voltage: The KY-032 module typically operates at a voltage range of 3.3V to 5V, making it compatible with most microcontrollers and development boards.

3- Digital Output: The module provides a digital output that can be easily interfaced with microcontrollers or other digital circuits. It produces a HIGH (logic 1) output when no obstacle is detected and a LOW (logic 0) output when an obstacle is detected within its detection range.

4- Adjustable Detection Range: The detection range of the KY-032 sensor can be adjusted using a potentiometer on the module. This allows you to fine-tune the sensitivity of the sensor according to your specific requirements.

5- Applications: The KY-032 Infrared Sensor can be used in various applications, including obstacle detection and avoidance in robotics, line following robots, proximity sensing, object detection, and security systems.

When using the KY-032 Infrared Sensor, it's important to keep in mind that it primarily detects the presence of objects based on their reflective properties rather than their distance. The effectiveness of the sensor can be affected by factors such as ambient light and the reflective properties of the objects being detected.

How to receive the Micro:bit board an infrared signal from the remote control using the KY-032 sensor?

To receive an infrared signal from a remote control using the KY-032 sensor with a Micro:bit board, you'll need to follow these steps:

1- Connect the KY-032 sensor to the Micro:bit board. The KY-032 module typically has three pins: VCC (power), GND (ground), and OUT (output). Connect the VCC pin to a 3.3V pin on the Micro:bit, the GND pin to a ground pin, and the OUT pin to any digital input pin on the Micro:bit.

2- Import the necessary libraries. In your Micro:bit programming environment (such as MakeCode or MicroPython), import the libraries required for infrared communication. For MakeCode, you can use the "infrared" extension, which provides blocks for working with infrared signals. For MicroPython, you may need to install additional libraries specific to the KY-032 module.

3- Configure the Micro:bit to receive infrared signals. Use the appropriate programming blocks or functions to set up the Micro:bit to receive infrared signals. In MakeCode, you can drag and drop the "on infrared received" block and define the actions to be performed when an infrared signal is received. In MicroPython, you'll need to write code to initialize the infrared sensor and define an event handler for handling received signals.

4- Program the Micro:bit to interpret the received signal. Depending on your project's requirements, you'll need to decode and interpret the received infrared signal from the remote control. This typically involves checking the specific codes transmitted by the remote control for different buttons or actions and responding accordingly.

5- Test and iterate. Upload the program to the Micro:bit and test it by pressing buttons on the remote control. Monitor the output on the Micro:bit to ensure that it correctly receives and interprets the infrared signals from the remote control. If needed, make adjustments to the program or the sensor's sensitivity to improve performance.

The components needed to use the KY-032 infrared sensor with the Micro:bit board

To use the KY-032 infrared sensor with the Micro:bit board, you will need the following components:

1- Micro:bit board:

Micro:bit board

The Micro:bit is a compact microcontroller board with built-in sensors and programmable through various programming environments such as MakeCode and MicroPython.

2- KY-032 infrared sensor module:

KY-032 infrared sensor module

The KY-032 module itself, which consists of an infrared emitter (LED) and an infrared receiver (phototransistor) placed side by side. It can detect infrared signals and provide a digital output based on the presence or absence of obstacles.

3- Jumper wires:

Jumper wires

You will need jumper wires to establish connections between the Micro:bit board and the KY-032 sensor. These wires typically have male-to-male connectors at both ends.

4- The GPIO expansion card for the Micro:bit card

The GPIO expansion card for the Micro:bit card

The GPIO expansion board for the Micro:bit board expands the capabilities of the Micro:bit board by adding more input/output (GPIO) pins and additional functionality.

5- Breadboard

Test plate

The breadboard is a common tool used in robotics and electronics to create circuit prototypes and temporary connections. It makes it easy to test and connect electronic components together without having to solder the connections.

These components are the basic requirements for using the KY-032 infrared sensor with the Micro:bit board. Additionally, you may need a remote control that transmits infrared signals to test the functionality of the sensor.

Mounting the Micro:bit board with the KY-032 infrared sensor

To mount the Micro:bit board with the KY-032 infrared sensor, you can follow these steps:

1- Prepare the KY-032 sensor: The KY-032 sensor module typically comes with mounting holes or slots on its PCB (Printed Circuit Board). These holes or slots allow you to secure the sensor in place using screws or other fasteners. Make sure the sensor is in good working condition and ready for mounting.

2- Determine the mounting position: Decide where you want to mount the KY-032 sensor in relation to the Micro:bit board. Consider factors such as the sensor's field of view and the location where it will detect infrared signals effectively. You may want to position it in a way that maximizes its coverage or aligns it with the expected path of the infrared signals you want to detect.

3- Attach the Micro:bit board: Place the Micro:bit board on a surface or a platform near the desired mounting position for the KY-032 sensor. You can use double-sided adhesive tape or a mounting bracket to secure the Micro:bit board in place. Make sure it is firmly attached and stable.

4- Connect the KY-032 sensor: Use jumper wires to establish the necessary connections between the Micro:bit board and the KY-032 sensor. Connect the VCC (power) pin of the KY-032 to a 3.3V pin on the Micro:bit, the GND (ground) pin of the KY-032 to a ground pin on the Micro:bit, and the OUT (output) pin of the KY-032 to pin P0 on the Micro:bit. Ensure the connections are secure and well-insulated.

Mounting the Micro:bit board with the KY-032 infrared sensor

Mounting the Micro:bit board with the KY-032 infrared sensor

Makecode programming of the Micro:bit board to receive data from the KY-032 infrared sensor

To use the KY-032 infrared sensor with the Micro:bit board and program with MakeCode, you can follow these steps:

1-Access the MakeCode for Micro:bit code editor by visiting https://makecode.microbit.org/.

2- Start a new project.

3- Add the necessary packages for the infrared sensor. Click on the "Advanced" category in the toolbox on the left, and then click on "Extensions".

3- In the search bar, type "https://github.com/osoyoo/OSOYOO_IR_V3/" and click on the "OSYOO-IR-Silvery-Receiver" extension to import it into your project.

4- Initialize the KY-032 infrared sensor:

Insert a "on start" block from the "Basic" category to initialize the program when the Micro:bit board starts. makecdoe-on-start

Insert the "connect IR receiver at pin P0 and decode OSOYOO" block from the "OSYOO_SilveryIR_V3" category to initialize the KY-032 sensor. Specify the pin to which the sensor is connected (for example, P0).

5- Add an event handler for receiving infrared signals :

Insert an "on IR Button" block from the "OSYOO_SilveryIR_V3" category to trigger an action when the infrared signal is received and specify the button on the remote control.

Inside the "on IR Button" block, you can add blocks to perform specific actions based on the received code. For example, displaying the key number on the Micro:bit board display.

6-Connect and upload the program:

Connect your Micro:bit card to the computer using a USB cable.

Click the "Upload" button in the code editor to upload the program to the Micro:bit board.

Here is an example of the Makecode program which displays the number of the key pressed on the remote control on the display of the Micro:bit card.

Download program

0 comment

Leave a comment

Veuillez noter s'il vous plaît*

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Purpose of this website

Educational robotics refers to the use of robots and robotics technology to promote learning in educational settings. It involves the integration of technology, engineering, and computer science into the classroom, allowing students to engage in hands-on, project-based learning experiences.
In this context, our website represents an excellent resource for parents, teachers and children who wish to discover robotics.

Contact details

Zaouiet Kontech-Jemmel-Monastir-Tunisia

+216 92 886 231

medaliprof@gmail.com

Pictures of the articles

Robotic site created by MedAli-Teacher info