Remotely light up an LED by remote using Micro:bit

Micro:bit 10-07-23
334 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 LED with the Micro:bit board

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

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

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 LED 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- LED (Light Emitting Diode):

Red LED

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.

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.

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

Once you have these components ready, you can follow these steps to connect and use them with the Micro:bit board:

1- Connect the VCC (power) pin of the KY-032 sensor to the 3.3V pin on the Micro:bit board.

2- Connect the GND (ground) pin of the KY-032 sensor to any GND pin on the Micro:bit board.

3- Connect the OUT pin of the KY-032 sensor to any digital input pin (P1) on the Micro:bit board. Make sure to keep track of the pin you use for programming.

4- Connect the anode (longer leg) of the LED to a current-limiting resistor (around 220 ohms) and connect the other end of the resistor to digital input pin (P0) on the Micro:bit board.

5- Connect the cathode (shorter leg) of the LED to GND pin on the Micro:bit board.

Now, you can write code on the Micro:bit board to control the KY-032 sensor and LED. You can use the Micro:bit's programming environment, such as Microsoft MakeCode or MicroPython, to program the board and interact with the sensor and LED.

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

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

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

To program the Micro:bit board using Microsoft MakeCode to receive data from the KY-032 infrared sensor and light up an LED 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, P1).

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- 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 an LED by a remote control

Download program

 

Now, when you press the selected button on your infrared remote control in front of the KY-032 sensor, the LED connected to the chosen pin will light up. Make sure you understand the pinout and specifications of your KY-032 sensor for proper use with the Micro:bit board.

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