kidsbits WiKi

KD2124 kidsbits Desktop Tutorial-V2.0

  • Introduction to Coding Box
  • KidsBlock Tutorial
  • MicroBlocks Tutorial
    • 1.Codes Download
    • 2.MicroBlocks Basic Tutorial
    • 3.Tutorial
      • 3.1 LED Blink
        • 3.1.1 Overview
        • 3.1.2 Schematic Diagram
        • 3.1.3 Code Blocks
        • 3.1.4 Test Code
        • 3.1.5 Test Result
      • 3.2 Sound Sensor
      • 3.3 PIR Motion Sensor
      • 3.4 Power Amplifier
      • 3.5 Photoresistor
      • 3.6 AD Button
      • 3.7 Ultrasonic Sensor
      • 3.8 RFID Sensor
      • 3.9 Axis-X&Y Joystick Module
      • 3.10 Temperature and Humidity Sensor
      • 3.11 Pressure Sensor
      • 3.12 Geomagnetic Sensor (Compass)
      • 3.13 Fan Module
      • 3.14 Servo
      • 3.15 WS2812 RGB LED
      • 3.16 OLED Display
      • 3.17 Traffic Lights
      • 3.18 Breathing LED
      • 3.19 Button Control LED
      • 3.20 Intrusion Alarm
      • 3.21 Window Close In Dark
      • 3.22 Voice Control Light
      • 3.23 Human Body Piano
      • 3.24 Button Control Fan
      • 3.25 Auto-door
      • 3.26 Access Card
      • 3.27 Auto-fan
      • 3.28 Environment Monitoring
      • 3.29 Car Backing Radar
      • 3.30 RGB Ring Clock
      • 3.31 Joystick Control Servo
      • 3.32 Ultrasonic Ranger
      • 3.33 wifi
      • 3.34 wifi Real-time Display
      • 3.35 WiFi Control
      • 3.36 wifi Piano
      • 3.37 Smart Control Panel
  • MicroPyhton Tutorial
kidsbits WiKi
  • MicroBlocks Tutorial
  • 3.1 LED Blink
  • View page source

3.1 LED Blink

3.1.1 Overview

LED Blink is one of the simplest entry-level programming projects for the ESP32 Coding Box. It only needs an LED and then upload the code. This simple project helps beginners better master basic concepts.

3.1.2 Schematic Diagram

t40

LED lighting on: The output current of the IO ports is limited, so the LED brightness may not be enough. Therefore, a NPN triode (Q2) is added to the circuit as a switch. We only need to add a high(low) level at the triode base pin 1 to light it up(out).

Triode on/off: To put it simple, when the base(pin 1) receives a high level, the collector(pin 3) and the transmitter(pin 2) are connected, so then VCC passes through the current-limiting resistor to the LED and then into the triode to GND, forming a loop. At this time, LED is on. When pin 1 receives a low level, pin 3 and 2 are disconnected so the current loop cannot be formed, resulting LED off.

3.1.3 Code Blocks

Blocks in :

  1. t1 is in “Control” class. Click the green image-20250411084853429 to run the code. These hat blocks monitor the various conditions described in their titles. When the startup condition is true, when started will be activated. The others are to check whether the button status or Boolean conditions are true to determine whether to execute the blocks placed under them.

  2. t2, a C-shaped block, also called LOOP, is a set of control blocks. As long as the conditions described in it are true, the inside codes will run. This repetitive execution will run the code blocks inside it forever. It is often used for plotting numerical values or continuously monitoring port values, etc.

  3. t4 pauses the execution flow for the specified number of milliseconds. It is used to pause and resume the execution in a time-controlled manner. Unit conversion: 1 second = 1000 milliseconds


Blocks in :

  1. t3 is a block included in coding box library. It can control the red, yellow and green LED on/off on the coding box. Click to choose an LED and tap t6 to turn off it. t6 means ON, and t7 is OFF.

3.1.4 Test Code

You can manually build blocks, or directly open the code file we provide: 3-1-LED.ubp. If you have any questions about how to open code files or upload code, please back to 1.9 Upload Code.

Build code blocks:

  1. In , drag and to the script area, and stack them together.

t34

  1. In , drag t3 block and place it in .

t35

  1. In , drag t4 block and modify 500 into 1000, and put it under t3.

t36

  1. Move your mouse onto t3 and click to choose duplicate all. Put the copy under the above blocks and set t3 to t37.

t38

Complete code:

t39

3.1.5 Test Result

Connect the coding box to the MicroBlocks via USB or Bluetooth, and click t59 to upload the code to the coding box. The red LED will blink with an interval of 1 second. If you want it to flash faster, modify the delay.

Previous Next

© Copyright Shenzhen kidsbits Technology Co., Ltd.

Built with Sphinx using a theme provided by Read the Docs.