Control three LEDs by Micro:bit card

Micro:bit 02-06-23
163 0

Tutorial plan

1- Role of LEDs in robotics

2- The components needed to control three LEDs by Micro:bit

3- Mounting the Micro:bit board with three LEDs

4- Lighting three LEDs by the Micro:bit card

5- Turn on three LEDs alternately

6- Turn on three LED using the buttons on the Micro:bit board

 

Role of LEDs in robotics

LEDs (Light-Emitting Diodes) play various roles in robotics, offering both functional and aesthetic benefits. Here are some common roles of LEDs in robotics:

Indication and Status Feedback: LEDs are often used to provide visual feedback in robotics systems. They can be programmed to indicate the status of different components or subsystems. For example, an LED might indicate whether the robot is powered on, if a specific sensor is activated, or if a task or action is in progress.

Object Detection and Sensing: In certain robotic applications, LEDs are utilized as light sources for object detection and sensing. For instance, infrared LEDs can be used in conjunction with infrared sensors to enable proximity sensing or line following. By emitting light and measuring the reflected or blocked signals, the robot can detect and navigate its environment.

Communication and Signaling: LEDs can be employed as part of a communication system between robots or between a robot and humans. By using different colors, blinking patterns, or sequences, LEDs can convey specific messages or signals. For example, a robot might use LEDs to signal that it is ready to receive commands, indicate a specific error condition, or display a warning.

Decorative and Aesthetic Purposes: LEDs can also serve as decorative elements in robotics. They can be integrated into a robot‘s design to enhance its appearance or create visual effects. This is particularly common in educational or hobbyist robotics projects, where LEDs are used to make the robot more visually appealing or to give it a distinctive look.

Safety and Visibility: In certain robotic applications, LEDs are employed to enhance safety and improve visibility. For instance, robots operating in low-light environments or hazardous areas can be equipped with bright LEDs to make them more visible to humans or to indicate their presence.

The components needed to control three LEDs by Micro:bit

To control three LEDs using a Micro:bit, you will need the following components:

Micro:bit board: The Micro:bit is a small, programmable development board with built-in sensors and GPIO pins.Micro:bit board

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

LEDs: You will need three LEDs of your choice. These can be regular LEDs or RGB LEDs, depending on your project requirements.three_LEDs

Resistors: LEDs require current-limiting resistors to prevent them from burning out. The value of the resistor depends on the forward voltage and current rating of the LEDs. A typical value for a standard LED is around 220-470 ohms.Three resistors

Jumper wires: You will need jumper wires to connect the Micro:bit’s GPIO pins to the LEDs and resistors.Jumper wires

Breadboard (optional): If you prefer to use a breadboard for easy prototyping and connection, you can use it to connect the LEDs, resistors, and jumper wires.Test plate

With these components, you can connect the LEDs to the Micro:bit’s GPIO pins using the resistors to limit the current. You can then program the Micro:bit to control the GPIO pins and turn the LEDs on or off.

Mounting the Micro:bit board with three LEDs

Mounting three LEDs on a Micro:bit board is a common project that can be accomplished with a few simple steps. Here’s a step-by-step guide to help you:

1- Place your Micro:bit board on a flat surface.

2- Take three LEDs of your choice and identify their legs. LEDs have a longer leg called the anode (+) and a shorter leg called the cathode (-).

3- Connect the cathode  of the first LED to GND on the Micro:bit board. Use a jumper wire to make this connection.

4- Connect the anode of the first LED to the resistor’s leg. The other leg of the resistor should be connected to the pin P0 on the Micro:bit board.

5- Repeat steps 3 and 4 for the other two LEDs, connecting them to pins P1 and P2 on the Micro:bit board.

6- Make sure the resistors are connected to the cathodes of the LEDs and the other leg of each resistor is connected to the GND pin.

7- If you’re using a breadboard, you can connect the jumper wires to the appropriate pins on the Micro:bit board and insert the LED legs and resistors into the breadboard for a neat and organized setup.

Mounting the Micro:bit board with three LEDs

Lighting three LEDs by the Micro:bit card

Once the hardware setup is complete, you can write the code to control the LEDs using the Micro:bit‘s programming platform, such as MakeCode or MicroPython. Here’s an example using MakeCode:

1- Go to the MakeCode editor (makecode.microbit.org) in your web browser.

2- Drag and drop the “on start” block from the Basic category to the coding area.

3- Inside the “on start” block, add the following code:makecode-Lighting three LEDs by the Microbit card

4- Click on the “Download” button to transfer the code to your Micro:bit board.

Turn on three LEDs alternately

Once the hardware setup is complete, you can write the code to control the LEDs using the Micro:bit‘s programming platform, such as MakeCode or MicroPython. Here’s an example using MakeCode:

1- Go to the MakeCode editor (makecode.microbit.org) in your web browser.

2- Drag and drop the following blocks into the coding area:Makecode-Turn on three LEDs alternately

3- Click on the “Download” button to transfer the code to your Micro:bit board.

This code will continuously cycle through the three LEDs, turning on one LED at a time for one second and then moving to the next LED.

Turn on three LED using the buttons on the Micro:bit board

Once the hardware setup is complete, you can write the code to control the LEDs using the buttons on the Micro:bit board. Here’s an example using MakeCode:

1- Go to the MakeCode editor (makecode.microbit.org) in your web browser.

2- Drag and drop the following blocks into the coding area:makecode-Turn on three LED using the buttons on the Microbit board

3- Click on the “Download” button to transfer the code to your Micro:bit board.

This code continuously checks the status of the buttons on the Micro:bit board.

If Button A is pressed: the LED connected to pin P0 turns on., the LED connected to pin P1 turns on and the LED connected to pin P2 turns off

If Button B is pressed: the LED connected to pin P0 turns off, the LED connected to pin P1 turns off and the LED connected to pin P2 turns on.

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