MagicCode Lesson 04: Blinking a LED
MagicCode Lesson 4

Blinking a LED

Learn how to blink a LED

Components Required

Buy

Introduction

In this example, you are learning how to turn on and off a LED or any other actuator which can be controlled by a digital output such as relay, bulb, motor.

Theory

A digital output allows you to control a voltage with an electronic device. If the device instructs the output to be high, the output will produce a voltage (generally about 5 or 3.3 volts). If the device instructs the output to be lower, it is connected to the ground and produces no voltage. Here, Magicbit is the device and the output voltage is either 3.3V for HIGH and 0V for LOW.

Methodology

Magicbit is equipped with four onboard LEDs in Magicbit development board, Let’s select yellow LED (which is wired to D18)

 

Magicbit inbuilt LEDs

By setting the output state to a high of the LED pin will turn on the LED and by setting the output state to LOW will turn off the LED.

Script

Drag and Drop following blocks from Events, control, and MagicBit lists of the block palette and make the script.

Sample code block setup

Explanation

This program starts by clicking the Green flag. The forever block continuously runs the code held inside the block. The digital pin has been set to pin 18 because the Yellow LED has connected to the D18 pin on the board. The waiting time has been set to 1 second. According to the Script, the Yellow LED turn on for one second and turns off for one second continuously.

Related Posts
Leave a Reply