Turn on RGB LED module connected to Micro:bit via remote control

Micro:bit 22-10-23
132 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 RGB LED module with the Micro:bit board

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

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

 

 

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 RGB LED module with the Micro:bit board

To use the KY-032 infrared sensor and RGB LED module 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- RGB LED Module:

This module contains a red, green, and blue LED, allowing you to produce various colors by controlling the intensity of each color component.

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, RGB LED module, 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.

7- Rmote control 

Télécommande infrarouge

A remote control is a handheld device or instrument used to operate or manipulate electronic devices or systems from a distance.

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

To mount the Micro:bit board with the KY-032 infrared sensor and RGB LED module, 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- Connect pin R of the RGB LED module to pin P0 of the Micro:bit.

8- Connect pin G of the RGB LED module to pin P1 of the Micro:bit.

9- Connect pin B of the RGB LED module to pin P2 of the Micro:bit.

10- Connect pin GND of the RGB LED module to pin GND of the Micro:bit.

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

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

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

To program the Micro:bit board using Microsoft MakeCode to receive data from the KY-032 infrared sensor and light up RGB LED module 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 RGB LED module in red color by pressing the 1 key on the remote control.

9- Set the state of the block “digital write pin P0 to 0”  to turn off the red color by pressing the 2 key on the remote control.

10- Repeat steps 8 and 9 to turn on RGB LED module in green color and blue color

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 RGB LED module 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