kidsbits WiKi

KD2124 kidsbits Desktop Tutorial-V2.0

  • Introduction to Coding Box
  • KidsBlock Tutorial
    • 1.Tutorial Codes Download
    • 2.KidsBlock 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.4.1 Build Code
        • 3.1.4.2 Test Result
        • 3.1.5 Extension
        • 3.1.5.1 Test Code
        • 3.1.5.2 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 (Direction Recognition) Geomagnetic Sensor
      • 3.13 Fan/Motor Module
      • 3.14 Servo
      • 3.15 WS2818 RGB LED
      • 3.16 OLED Display
      • 3.17 Traffic Light
      • 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 Compass
      • 3.34 WiFi
      • 3.35 WiFi Real-time Display
      • 3.36 WiFi Control
      • 3.37 WiFi Piano
      • 3.38 Smart Control Panel
  • MicroBlocks Tutorial
  • MicroPyhton Tutorial
kidsbits WiKi
  • KidsBlock 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. It only needs an LED and then upload the code This simple project helps beginners better master basic concepts.

3.1.2 Schematic Diagram

6-1-2

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

  1. j1

    The start of the execution of a code. Codes will not run without this block. The module blocks that need to be initialized should be added below the block.

  2. j2

    Code run in here and are executing all the time (in a loop).

  3. j3

    This block controls the ON/OFF of an LED. You only need to set the pin and power level(HIGH/LOW).

  4. j4

    The delay seconds can be modified as needed.

    Unit: s.

    Some conversions: 1S=1000mS; 1mS=1000uS; For instance, if a delay of 10ms is required, input 0.01.

3.1.4 Test Code

3.1.4.1 Build Code

There are two ways to upload the code: directly open the code file we provide; or manually build blocks.

Directly open the code file we provide:

  1. Click and choose Load from your computer

  1. We have already downloaded the codes on computer desktop, so open the file and choose 3-1-led.sb3

Manually build blocks:

  1. In events, find j1 block.

  2. In control, find and place j2 block under j1.

6-1-4-1-1

  1. In image-led, drag and put j3 block into j2. Set pin to IO23 and output to HIGH.

6-1-4-1-2

  1. In control, add a delay j4 of 500ms. So we set it to 0.5s.

6-1-4-1-3

  1. Right-click j3 and you will see j5. Choose Duplicate and put the copy under 6-1-4-1-4:

6-1-4-1-5

  1. Modify j3 output into LOW.

3.1.4.2 Test Result

After uploading code, the red LED will blink with an interval of 0.5 seconds.

3.1.5 Extension

If you want the LED to blink more frequently, just modify the delay time in j4. If we set the time shorter, it will blink faster. Now let’s set it to 0.25s.

3.1.5.1 Test Code

There are two ways to upload the code: directly open the code file we provide; or manually build blocks.

Directly open the code file we provide:

  1. Click and choose Load from your computer

  1. We have already downloaded the codes on computer desktop, so open the file and choose 3-1-led2.sb3

Manually build blocks:

Build code blocks as above but set delay to 0.25.

3.1.5.2 Test Result

After uploading code, the red LED will blink with an interval of 0.25 seconds. Compared to 3.1.4.1, it blinks more frequently.

Previous Next

© Copyright Shenzhen kidsbits Technology Co., Ltd.

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