Posted 2017-09-04 12:34:22 +0100

blogs->all

# Micro:bit Experiment 01: LED Scroller —— Elecfreaks Mirco: bit Starter Kit Course

No tags

Introduction:

LED has wide applications. We can see most signal lights we saw in our daily life use LED as its major illuminate component. In today’s experiment, we are going to use Micro:bit to make 2 LED beads twinkle alternatively.

Components List:

Hardware:

1 X Micro USB Cable

2 X LED

2 X 100 Ohm Resistors

Tips: If you have bought Elecfreaks Micro: bit Starter kit, it will conclude all of the above components.

Software:

Microsoft Makecode online Editor

Major Component Introduction

Micro: bit Breadboard Adapter can extend all footers of Micro: bit to breadboard so that we can create Micro: bit circuit on breadboard easily.

LED

LED is abbreviated from Light Emitting Diode. It is a kind of semi-conductor diode. It can transfer electric to light. And if there is current flow, it can emit light.

If you look carefully at the LED you will notice two things. One is that the legs are of different lengths and also that on one side of the LED, instead of it being cylindrical, it is flattened. These are indicators to show you which leg is the Anode (Positive) and which is the Cathode (Negative). The longer leg gets connected to the positive supply (3.3v) and the leg with the flattened side goes to ground.

Resistance

Resistance is a component for limiting current. It can limit the current of the circuit connected. And in our experiment, we use 100Ω resistance. If there is no current limit, LED will be ruined.

If you want to know resistance value by color circles, you can refer to this article: How to Identify Color Circle Resistance Value.

Hardware Connection

You can complete hardware connection according to the picture below:

After connection, you will see:

Programming

Open Microsoft Makecode, coding like the picture showed below on editor interface.

https://makecode.microbit.org/#pub:_aPtRppeup0E5


Code Explanation:

Forever

The forever block is a block that loops any other command blocks inserted into it over and over again…forever. It starts from the top and executes your code in order working its way to the bottom and then starts at the top again.

Digital Write

The DigitalWrite block enables you to turn a pin on or off. There is a dropdown option for which pin you want to control, and it accepts a variable as the pins state. You use 1 as on and 0 as off. If you prefer, you can also use Boolean states of true and false, but we will use 0 and 1 as our standard throughout this guide.

Pause

If you were to just turn pins on and off with the digital write block without a pause, the LED would blink really, really fast. The pause block enables you to slow the micro: bit down and lets you control the timing of things happening. It accepts a number or variable as the number of milliseconds you want the micro: bit to pause. Think of this block as a stoplight for your code!

Experiment Result

You can see 2 LED flashing alternatively. If you do not get this result, go back and check your operations.

Question:

If we want to control 4 LED beads and make it illuminate by turns, then how shall we design our circuit and make program. We would like to receive your further discussion with us. You can leave your comment below.

Posted Sept. 4, 2017, 12:37 p.m.

View this Course from: https://www.elecfreaks.com/9784.html

## Recent blog posts

• ### Difference between nRF52840 Engineering A and B reference designs

Posted 2018-01-15 12:27:08 by Martin Børs-Lind
• ### [For Hire] Expert development services of custom Hardware devices | IoT solutions | Mobile Apps

Posted 2018-01-15 09:08:42 by Ilya Surinsky
• ### Rust bindings to nrf52 series

Posted 2018-01-12 23:23:07 by Coleman McFarland
• ### Show And Tell: Poly - Building an RC Airplane The Hard Way

Posted 2018-01-05 01:17:57 by Daniel Veilleux
• ### Bluetooth on a desktop computer (Windows, Mac, Linux)

Posted 2018-01-04 17:56:57 by kbaud

## Recent questions

• ### System off draws more then 80µA

Posted 2018-01-22 22:15:19 by ruetten
• ### How to add driver to an SDK example, in Segger Embedded Studio?

Posted 2018-01-22 21:37:18 by Mark Leavitt
• ### Send more than 60 characters with each call to ble_nus_string_send

Posted 2018-01-22 21:20:21 by fkoran
• ### DFU succeeds but flash is erased

Posted 2018-01-22 20:42:54 by brett_anderson
• ### Uart example stops blinking after a while

Posted 2018-01-22 19:56:29 by oliverpoc