Remotely light up three LEDs by the remote control using the KY-032 infrared sensor and the Micro:bit card

Micro:bit 15-07-23
167 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 and three LEDs with the Micro:bit board

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

6- Makecode programming of the Micro:bit board to receive data from the KY-032 infrared sensor and light up three LEDs

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 and three LEDs with the Micro:bit board

To use the KY-032 infrared sensor and LED with the Micro:bit board, you will need a few components and connections. Here’s a list of the required items:

1- Micro:bit board:

Micro:bit board

The Micro:bit board is a small, programmable microcontroller board designed for education and beginner-friendly coding projects. It was developed by the BBC, in collaboration with various partners, as a tool to introduce young people to programming and electronics.

2- KY-032 Infrared Sensor:

KY-032 infrared sensor module

This sensor detects infrared signals and can be used to detect objects or receive signals from a remote control.

3- Three LEDs (Light Emitting Diode):

A Light Emitting Diode (LED) is a semiconductor device that emits light when an electric current passes through it. LEDs are widely used in various applications due to their efficiency, small size, and low power consumption.

5- Three resistors

Three resistors

A resistor is a passive two-terminal electrical component that restricts or controls the flow of electric current in a circuit. It is one of the most common and fundamental components used in electronic circuits. The primary function of a resistor is to create a specific amount of resistance to the flow of electric current.

4- Breadboard:

Test plate

A breadboard is a useful tool for creating temporary electronic circuits. It allows you to connect components without soldering.

5- Jumper wires:

Jumper wires

These wires are used to make connections between the Micro:bit, KY-032 sensor, LED, and breadboard.

6- 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.[/vc_column_text]

I am text block. Click edit button to change this text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut elit tellus, luctus nec ullamcorper mattis, pulvinar dapibus leo.

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

To mount the Micro:bit board with the KY-032 infrared sensor and three LEDs, you will need a breadboard and some jumper wires. Here are the steps to connect them:

1- Place the Micro:bit board on the breadboard, ensuring that the edge connector is aligned with the breadboard’s power rails.

2- Connect the GND (ground) pin of the Micro:bit board to the negative (-) rail of the breadboard using a jumper wire.

3 – Insert the KY-032 infrared sensor into the breadboard. Make sure the sensor’s pins are aligned with different rows on the breadboard.

4- Connect the VCC pin of the KY-032 sensor to the 3.3V pin of the Micro:bit board using a jumper wire.

5- Connect the GND pin of the KY-032 sensor to the GND pin of the Micro:bit board using a jumper wire.

6- Connect the OUT pin of the KY-032 sensor to one of the pin P12 on the Micro:bit board using a jumper wire.

7- Insert the three LEDs into the breadboard. Ensure that the longer leg of each LED (anode) is connected to the positive (+) rail of the breadboard.

8- Connect the longer leg of one LED (cathode) to a current-limiting resistor (around 220-470 ohms) using a jumper wire.

9- Connect the other end of the current-limiting resistor to a digital output pin on the Micro:bit board. Choose P0, P1 and P2 and connect it using a jumper wire.

10- Connect the shorter leg of the second LED (cathode) to the negative (-) rail of the breadboard using a jumper wire.

Mounting the Micro:bit board with the KY-032 infrared sensor and three LEDsMounting the Micro:bit board with the KY-032 infrared sensor and three LEDs

Makecode programming of the Micro:bit board to receive data from the KY-032 infrared sensor and light up three LED

To program the Micro:bit board using Microsoft MakeCode to receive data from the KY-032 infrared sensor and light up three LEDs based on the received data, you can follow these steps:

1- Open the MakeCode editor for Micro:bit at https://makecode.microbit.org/.

2- Start a new project or open an existing one.

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”.

4- 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.

5- 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, P12).

6- 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 button on the remote control.

7- Insert a block “digital write pin P0 to 0” inside the block “on IR button 1 pressed”.

8- Set the state of the block “digital write pin P0 to 0” to “1” to turn on the LED by pressing the 1 key on the remote control.

9- repeat steps 6, 7, 8 and 9 to turn off the LED by pressing button 2 on the remote control.

10- Insert a block “digital write pin P1 to 0” inside the block “on IR button 1 pressed” to turn off the green LED by pressing key 1 of the remote control.

11- Insert a block “digital write pin P1 to 0” inside the block “on IR button 2 pressed” and change the value 0 to 1 to turn on the green LED by pressing the 2 button on the remote control.

12- Upload the program to your Micro:bit board by connecting it to your computer via a USB cable and clicking the “Upload” button in the MakeCode editor.

Here is the complete program which allows to turn on and off two LEDs by a remote control

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