Scratch Tutorial

1.Software Installation

Reference: https://kidsblocks.readthedocs.io/

Windows System

  1. How to Download:

  2. After downloading, click “KidsBlock.exe”img

  3. Tick “Anyone who uses this computer(all users)”, and click “Next”.

img

  1. Click “Browse…” to choose a path for your downloading. Here I put it in Disk C. And then click “Install”.

img

img

  1. After completing the installation, click “Finish” to open Kidsblock.

img

  1. If there is a warning, just click “Allow access” to re-open Kidsblock.

img


MacOS System

  1. Kidsblock Package Download: http://xiazai.keyesrobot.cn/KidsBlock.dmg

img

  1. After downloading, click KidsBlock. Drag KidsBlock Desktop into File Applications.

img

  1. After installation, you will see KidsBlock icon:

    img

  2. Tap KidsBlock. If it cannot be opened, we shall modify some computer settings. It is because that, by default, Mac Book only opens software from App Store.

    img

  3. Open Settings and click Privacy & Security. Tick “App Store and identified developers”, and tap “Open Anyway”.

    img

  4. Click Open.

    img

  5. After settings, Kidsblock can work normally.

    img

  6. Here is the main page of Kidsblock. Now enjoy your programming journey!

    img


Kidsblock Startup

Here we demonstrate on Windows.

Overall Function Description 1: Toolbar

img


Select Language

Click img to choose a language: img


Install Driver

NOTE: If you computer is already installed a driver, please skip this step. If not, please operate as follows.

  • Click img to choose “Install driver”.

img

  • Pop up a “Device Driver Installation Wizard”, and click “Next”.

img

  • Click “Finish”.

img

  • Next”.

img

  • And “Finish”.

img

  • If there is a warning, click “Allow” and “Install”.

img

  • After installing successfully, click “Finish”.

img

  • Click “Extract”.

img

  • Next”.

img

  • Tick “I accept this agreement” and “Next”.

img

  • After completing installation, click “Finish”.

img

  • Click “INSTALL”.

img

  • Then “OK”.

img


Select a Hardware
Board And Port
  • Click img to select a main control board.

  • Click Kit to choose RGB LED cube. All needed sensors are integrated in this kit, so that you do not have to add them by yourself.

    img

  • Import the kit and back to main page, and you will see a interface with all connectable devices. Find the correct one to Connect.

    img

  • Go to Editor.

    img

  • Main interface:

    img

Disconnection
  • Click img firstly.

  • Then click Disconnect.

    img


Overall Function Description 2: Areas

img


Add Modules

NOTE: All needed modules are integrated in this kit, so you may skip this part. If you want to use some sensors which are not included in this kit, please take this section as a reference.

  • Click img.

  • Choose an extension.

    img

  • Take passive buzzer as an example. Click “Passive buzzer”.

    img

  • Not loaded” is shifted to “Loaded”, and this sensor codes is successfully imported.

    img

  • Click img to back to editor, and you will see the Passive buzzer blocks.

    img

  • If you want to delete this extension, click img.

  • Find and click passive buzzer.

    img

  • Loaded” becomes “Not loaded”, and it is removed from blocks.

img


Open Codes

Method Ⅰ
  • If Kidsblock is closed, click SB3 files to directly open the code. For instance, click img to open it, and choose the correct board and port.

    img

Method Ⅱ

  • Click “file” and choose “Load from your computer”.

    img

  • Find the SB3 file on your computer, like img.

    img

    img


Upload Code

  • Import img to Kidsblock.

  • Connect the board to your computer and choose the corresponding port, click img.

    img

  • Wait for uploading.

    img


Set Baud Rate

  • Set the print box at the right-upper corner: img

    • Small print box: img

    • Large print box: img

    • No print box: img

  • Click img to set baud rate.

    img

  • Then you will see “Hello KidsBlock” is being printed in the box.

img



2.Projects

2.1. Startup: An Adventure in The World of Light


In this project, we will guide you to explore the fantastic cube on its structure, working principle and applications. Now build your cube to get your journey started!


Brief Introduction: What Is An RGB Cube?

A 4x4x4 RGB Cube consists of 64 RGB (tricolor of red, green and blue) LED and their drive circuits, a microcontroller(MCU), and its transparent housing (acrylic board usually). Each LED, separately, emits any color in RGB, hence polychrome patterns and colorful shows can be devised with your creativity through different color combinations.

535f024290107476061c7a13a2017a5d


Basic Construction: What Is The Cube Composed?

RGB Cube integrates ATmega32u4 as its main control chip at the bottom to control all 64 RGB LED, whose using method is entirely the same as the Leonardo development board.

2023-08-12_103144

This cube consists of totally 4x4x4=64 LED.

2023-08-12_130342

To expatiate, four 4x4 matrix are piled one above another to form a 3D Cube. Still, each sole RGB LED can be controlled to light up in planed colors.

2023-08-12_101233

Similarly, each matrix can also work separately.

2023-08-12_101710

Certainly, you can choose to light up all RGB LED on the cube.

2023-08-12_101913


Working Principle: How Does The Cube Work?

For short, all the RGB LED and their colors’ permutation and combination are controlled by an MCU.

7914e6039f108df01af6ff8a187cc183

Due to the considerable RGB LED, it is unrealistic to control them via IO pin on mainboard one by one. By comparison, a drive circuit satisfies the need — it is called MCU 32U4+MY9262 Driver Module.

2023-08-12_105911

With 32U4, data is transmitted to the driver module to run commands of lighting up each RGB LED, so that the cube is in a light show.

2023-08-12_110407


Unlimited Ingenuity!

In this project, we get a preliminary understanding of the concept, composition and working principle of the cube, which lays a solid foundation for the following exploration and originality!

Next, please continue your learning on its applications and operational skills! Whether you are a beginner or an experienced developer, learning Arduino will be very joyful and challenging.

Let’s keep going!


2.2.Shining Journey: A Unique Cube


First of all, you will learn Arduino programming to know how to light up LED lights and to control the cube via code. Implementing simple light shows, gives you the foundation to explore more creative control methods.


First Experience: Light Up The Cube

Background Knowledge

In terms of hardware, it communicates with the driver module through the 32U4 main control chip to control 64 RGB LED, which simplifies the IO pins on the main control chip.

The operation guide of driver module MY9262:

2023-08-12_132854


Communication Command:

Instruction Name

Number of DCK Pulses when LAT is at High

Function Description

Data Latch

0 or 1

Strobes image data into temporary registers. In this time, constant current outputs are not updated to a new frame data.

Global Latch

2 or 3

Strobes image data from temporary registers into an APDM/PWM generator. In this time, constant current outputs are updated to a new frame data.

Reading Command

4 or 5

Read out command data from the command latch cell to the 16bits shift registers. And thecommand data could shift out from DO pin by serial DCK pulses.

Writing Command

10 or 11

Strobes command data from the 16bits shift register into the command latch cell. Note that this instruction must follow by the “Enable Writing Command” instruction.

Reset APDM/PWM Counter

12 or 13

This instruction will reset APDM/PWM counter to synchronize a new frame if CMD[11]=”H”.

Enable Writing Command

14 or 15

This instruction enables the “Writing Command”instruction. This instruction should be executed before the “Writing Command” instruction every time.


Command Operation:

  • Data Latch :

    2023-08-12_134425

  • Global Latch :

    2023-08-12_134512

  • Reading Command :

    2023-08-12_134627

  • Writing Command :

    2023-08-12_134659

  • Reset APDM/PWM Counter (set CMD[11]=”1”):

    2023-08-12_134713


Command Data Format

2023-08-12_135023


Data Bit:

2023-08-12_135300


Image Data Format

2023-08-12_140029


Data Transmitting Protocol

  • MODE0 ( CMD[15]=“0” )

    2023-08-12_140311

  • MODE1 ( CMD[15]=“1” )

    2023-08-12_140323


Data Synchronization

  • Auto Synchronization ( CMD[10]=“0” )

    2023-08-12_140512

  • Manual Synchronization ( CMD[10]=“1” )

    2023-08-12_140614


On the basis the previous theory, data will be sent according to the register information of MY9262, and that is how the driver module communicate. For beginners, libraries and tutorials are provided to make operations easier.


Description of Library

Open Arduino IDE to import the Cube libraries.

2023-08-12_162006


  • Initialize.

    KidsBlockProject-1693897616365

  • Light up all RGB LED

    • 1.All LED in one color

      KidsBlockProject-1693897590845

    • 2.All LED in RGB color

      KidsBlockProject-1693897565116

  • Light up single LED in RGB color in axis x, y, and z

    KidsBlockProject-1693897467020

    2023-08-12_162543

  • By line segments: Given positions of Point A(X1,Y1,Z1) and B(X1,Y1,B1), the RGB LED between A and B will light up.

    1. KidsBlockProject-1693897514772

    2. KidsBlockProject-1693897530988

    2023-08-12_163111

  • By solid squares:

    1. KidsBlockProject-1693897645573

    2. KidsBlockProject-1693897656301

      Light up a 4x4 matrix:

    2023-08-12_164348

  • By sphere: Given the position of Point A as a center, draw a sphere with a variable size.

    NOTE: The sphere will not show up if its size is too big or small.

    1. KidsBlockProject-1693897756253

    2. KidsBlockProject-1693897789326

    2023-08-14_083012

  • By box: Given the position of Point A as the starting point, draw a box with a variable size.

    NOTE: The box will not show up if its size is too big or small.

    1. KidsBlockProject-1693897808422

    2. KidsBlockProject-1693897838975

    2023-08-14_083012

  • 11 light effects are included.

    2023-09-23_104805


Lighting-up Codes



Beginner: Light Effects

Water Flow LED on Axis
  • Find Variables and click Make a Variable.

    2023-09-05_164816

  • Define a mew variable as x.

    2023-09-05_165413

    2023-09-05_171753

  • Initialize

    KidsBlockProject-1693897945849

  • In forever block, set x to 0, and repeating times to 4.

    KidsBlockProject-1693905574411

  • Add a Single LED block and put the variable x in axis x. Set display color in red 255, green 0, blue 0. And delay 1s.

    NOTE: Put the Single LED block above the change by 1 block (x adds 1).

    KidsBlockProject-1693905648788

  • After repeat block, clear the RGB LED color display, so that it is convenience for observing.

    KidsBlockProject-1693905829486

  • Upload code to the cube, and you will see a single line water flow LED.

    2023-09-05_172703

    2023-09-05_172635

  • Water flow LED on three axis.

    Add a variable i and three Single LED block. Put i into axis X, Y and Z, and set their colors.

    KidsBlockProject-1693906340283

Water Flow LED on Plane
  • Initialize

    KidsBlockProject-1693897945849

  • In forever block, define a variable i and set repeating times to 4.

    KidsBlockProject-1693907730064

  • In repeat block, add a Plane cube block and set i as direction. Set color to red 0, green 255, blue 0, and put a change by 1 block under it. Delay 1s. Now a water flow LED is on axis X.

    KidsBlockProject-1693907912762

  • After repeat block, clear the RGB LED color display, so that it is convenience for observing.

    KidsBlockProject-1693908049235

  • Water flow LED on three axis.

    Define a variable i and three Plane cube block. Put i into axis X, Y and Z, and set their colors.

    KidsBlockProject-1693960315205


Deep Experience: Light Up Cubes

**Cascading interfaces are reserved on the cube, which can connect multiple cubes in series. In cascade mode, only one cube is the master device that controls lights, while others are slave ones that need to clear codes and are not allowed to run codes, otherwise tests are with no results). **

The cascading interface, as follows, can be quickly connect via pins and connectors.

NOTE: Each cube contains many RGB LED and then loads a large voltage. Therefore, when multiple cubes are cascaded, please provide independent power supply to each to ensure stable operation of the system.

DEGE2-

Two cubes are cascaded as follows:

4c2e4f07d755521f86a132bc2209540


FAQ

Q: How to determine the axis X, Y, and Z on the RGB Cube?

A: The direction of the X and Y axis is marked on the main control board, and the Z axis is perpendicular to them.

Q: With multiple RGB Cube connected, error occurs.

A: The master RGB Cube is used to control the lights. Please clear their codes in other connected Cubes.


2.3.Magical Fingertip: Button And Light


In this project, a button module is integrated with this cube to control lights through programming, and codes will be written according to the working principle of this button module. With an external button, you may enjoy more joy and feel more involved in the entire experiment, and you will take sophisticated controlling methods much easier with the experience of this lesson.


A Button Module

Description

Button module is a simple input device whose power level is read by the MCU to determine its state (being pressed or released).

cou13

Principle Diagram

couy12

Parameters
  • Voltage: 3~5V

  • Current: ≤1.1mA

  • Power: ≤5.5mW

**The button works due to a built-in ON/OFF circuit. **

  • When the button is pressed, the circuit is closed(ON state) so that current passes from the button to GND, and a low power level is detected at the digital input pin on the development board.

  • When the button is released, the circuit is opened(OFF state) and the power level is pulled up by a resistor, thus the digital input pin detects a high level.


Wiring Diagram

Hold your RGB CUBE and look for the expansion interface at its bottom. Connect the wire to D6 pin.

NOTE: S(Signal) is in yellow, V(Voltage) is in red, GND is in black. When wiring, please pay attention to the color and do not reverse!

UntitledSketch_bb1


Code

  • Initialize. Set pin 6 to input mode.

    2023-09-06_083938

    KidsBlockProject-1693960921861

  • Initialize the serial port.

    KidsBlockProject-1693960966997

  • If the read button value is 1, print 1, or else, print 0. 1 means the button is released.

    KidsBlockProject-1693961690928

  • Button values will be printed on the serial monitor.

    • When the button is pressed, the monitor prints 0.

    • When the button is released, the monitor prints 1.

2023-09-06_085344


Expansion

Self-locking Button

A self-locking button will not pop up after you pressing it until you press it again, which is very similar to a switch. We adopt MCU to control the state of the circuit, and we reform the common button into a self-locking one via coding.

Code:

  • Initialize, and set pin mode and baud rate.

    KidsBlockProject-1693962197109

  • Define a variable b and set b to 0.

  • In forever block, detect the value at pin 6. Here we define 1 as that the button is released. We add a not block for negation and a delay of 20ms, which aims to eliminate the button jitter.

    KidsBlockProject-1693962967976

  • Add another if block in the exist one to determine the button value. (The previous one is used to eliminate the button jitter.)

    KidsBlockProject-1693963367677

  • If the button is pressed, set b to 0, or else, set b to 1.

    KidsBlockProject-1693963509766

  • Print b.

    KidsBlockProject-1693963617544

    • In serial monitor, when you press the button, b will be printed more than once.

      In the code, the button value is always being detected. When you press the button, the value is always 0, because the code will be circulated till value equals 1. So, we must add an wait until block to determine whether the button value is 1.

      2023-09-06_095333

      Then, when you press and hold the button, the code will not run repeatedly.

    Complete code:

    KidsBlockProject-1693965571650

Upload code and open the serial monitor. When you press the button, button value is 1. Press again and it will become 0. Now it becomes a self-locking button!

2023-09-06_100022


Button Switches Light

KS05754x4x4LED-7

Light Color Change

Press the button to shift the overall color of the cube.

  • Initialize.

    • Set pin 6 to input mode

    • Define a variable b and assign it to 0

    • Initialize RGB CUBE

    KidsBlockProject-1694069757782

  • Build a self-locking button code.

    2023-09-07_165659

  • Make a block named button.

    2023-09-07_165825

    2023-09-07_165944

  • In the self-locking button code, b adds 1 when the button is pressed once, and b circulates within 0~3, so that the button is able to control the lights.

    KidsBlockProject-1694077307948

  • Put the function in the forever block.

    KidsBlockProject-1694077348196

  • Add an if block and put a display block under it.

    KidsBlockProject-1694077579992

Complete code:

KidsBlockProject-1694077798554


Water Flow LED Change

The button can change the direction of the “water flow”.

  • Initialize

    KidsBlockProject-1694069757782

  • Add a button code.

    3.5RGBCUBE_Button_Self-Locking4-1694144987025

  • In forever block, put three if block to represent axis x, y and z. The button will change the water flow in all three axis.

    3.5RGBCUBE_Button_Self-Locking4-1694145196228

  • Add water flow LED on axis x, y and z.

    2023-09-07_165659

    2023-09-08_115651

    2023-09-08_131231

  • Add the water flow LED code in the function, and add variable x in circulation. Variable x adds 1 for each time.

    KidsBlockProject-1694150993474

  • Add a Plane cube block. Define x as direction and set display color.

    KidsBlockProject-1694151218469

  • Water flow LED on three axis

    KidsBlockProject-1694151398703

Complete code:

KidsBlocProject-1694151776444


FAQ

Q: RGB Cube detects the button in a poor sensibility.

A: Try to modify the delay time of jitter elimination to an appropriate time.

KidsBlockProject-1695187447165

Q: Serial monitor does not print values.

A:

  1. Please check whether the serial port is correct.

  2. Please check whether the baud rate is consistent with that in the code.

  3. Re-plug the USB cable.


2.4.Symphony of Colors: Innovation in Art of Light


TARGET: We will learn how to design and innovate the light effects and how to fade, blink and circulate light color.


Charm of Fading Color

Fade RGB LED

To fade an LED, we control the gradual change of LED brightness through the PWM output by the MCU.

Video_20230714105337

Pulse Width Modulation (PWM), is an effective technology using the MCU digital output to control analog circuits, which is applied to many fields, including measurement, communication as well as power control and conversion.

Pulse Width Modulation

Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between the full VCC of the board (e.g., 5 V on UNO, 3.3 V on a MKR board) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. The duration of “on time” is called the pulse width. To get varying analog values, you change, or modulate, that pulse width. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0 and VCC controlling the brightness of the LED.

Official Website: https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM

2023-08-17_193905

PWM includes several uses:

  • Dimming an LED.

  • Providing an analog output; if the digital output is filtered, it will provide an analog voltage between 0% and 100%.

  • Generating audio signals.

  • Providing variable speed control for motors.

  • Generating a modulated signal, for example to drive an infrared LED for a remote control.

The provided CUBE library includes the PWM method, so we can directly use to control RGB color within the value of 0~255.

2023-08-12_110407

The main control chip sends a command, and MY9262 driver module outputs PWM value to control the RGB LED.

Code

KidsBlockProject-1694151873237

  • We adopt for loop, which accumulate RGB from 0 to 255 so that RGB CUBE is gradually brighter.

KidsBlockProject-1694154408806

  • We adopt for loop, which decreases RGB from 255 to 0 so that RGB CUBE is gradually dimmer.

KidsBlockProject-1694154490534

Complete code:

KidsBlockProject-1694154495190

Code for gradual change in RGB color:

4.2RGBCUBE_PWM2-1694154597159



Integration Show of Light

  • BOX

KidsBlockProject-1694163231091

  • BOX and Sphere

4.4RGBCUBE_Random2-1695260804056

2.5.Glamour of Rotation: Potentiometer Plus Cube

In this project, a potentiometer is extended to the cube to control the RGB LED.


Potentiometer

Description

A potentiometer, also called rheostat, is an electronic component used to control current or voltage by adjusting its resistance value. Its resistance changes with a rotation so that the current changes according to Ohm’s Law.

cou14

Principle Diagram

2023-08-28_164050


Potentiometer and Cube

NOTE: S(Signal) is in yellow, V(Voltage) is in red, GND is in black. When wiring, please pay attention to the color and do not reverse!

asds


Code

4.4RGBCUBE_Random2-1695262034303

Upload code to the development board and open the serial monitor to set baud rate. Rotate the potentiometer and you will see the value on the monitor is changing.

2023-09-21_100623


“Rotate” Light!

KS05754x4x4LED-9

We can adjust lights via the map value.

Initial value: 0-1023

Map value: 0-255. It is converted from the initial value.

1. Change the color of RGB LED
  • Initialize

    4.4RGBCUBE_Random2-1695262872751

  • Add a map block. The read value A1(0~1023) is mapped to 0-255.

    4.4RGBCUBE_Random2-1695262885688

  • Create a variable ananlogvalue and map its value as its assignment.

4.4RGBCUBE_Random2-1695262898877

  • Print the map value and set display RGB color.

    4.4RGBCUBE_Random2-1695262907779

2.Change the position of RGB LED
  • Initialize

    4.4RGBCUBE_Random2-1695262872751

  • Add a map block. The read value A1(0~1023) is mapped to 0-3, which respectively means the coordinates on axis x, y and z.

    4.4RGBCUBE_Random2-1695263347060

  • Create a variable ananlogvalue and map its value as its assignment.

    4.4RGBCUBE_Random2-1695263397979

  • Print the map value and set display RGB color and axis x, y and z.

    4.4RGBCUBE_Random2-1695263401917


In this experiment, a potentiometer is extended to the cube to control the RGB LED. We design light effects through rotating the potentiometer whose value is read by coding. Herein, you may feel more joy and interactivity, and these experience will set you up for your future exploration in cube extension.


2.6.Ambient Resonance: The Wisdom of Light

In this project, a photoresistor is integrated with the cube to change the light effects according to the ambient light.


Photoresistor

Description

A photoresistor, also called photosensor, is an electronic component that converts light signal into electrical signal(voltage, current, resistance, etc.) through a kind of optoelectronic part. The core of this module is a built-in resistor whose value can be influenced by light.

cou16

Working Principle

The photoresistor is arranged in the circuit in series. After putting an appropriate voltage at both ends, when there is no light, the resistance value closes to be infinite, so the circuit can be regarded as opened. By contrast, the resistance will decrease if there is light, thus the current increases. With the light intensity up, the resistance is so low that causes a short circuit.

Next, we write code to read the value of the photoresistor through ESP32 development board.

Principle Diagram

Put a light on the photoresistor.

The brighter the light is, the lower the resistance value will be, and the greater the voltage(from VCC to the photoresistor) will be.

2023-08-29_143155

Parameters
  • Voltage: 3~5V

  • Current: 0.2mA

  • Power: 1mW

  • Spectral peak: 540nm

  • Bright resistance (10lux): 5~10KR

  • Dark resistance: 0.5MR


Photoresistor and Cube

NOTE: S(Signal) is in yellow, V(Voltage) is in red, GND is in black. When wiring, please pay attention to the color and do not reverse!

po


Code

  • Initialize

    4.4RGBCUBE_Random2-1695264522529

  • Add two variables analogvalue and mapvalue. Assign the read value on photoresistor to analogvalue and map value to mapvalue.

    4.4RGBCUBE_Random2-1695264541097

  • Print the two values.

    4.4RGBCUBE_Random2-1695264544129

Upload the code to development board and open the serial monitor to set the corresponding baud rate. Try to use your hand to cover the photoresistor, you will see the value printed on the monitor slumps.

2023-09-21_104652


Ambient Light and Cube

KS05754x4x4LED-6

1.RGB Cube changes with the ambient light.

  • Initialize

    4.4RGBCUBE_Random2-1695262872751

  • Add a map block. The read value A1(0~1023) is mapped to 0-255.

    4.4RGBCUBE_Random2-1695262885688

  • Create a variable ananlogvalue and map its value as its assignment.

    4.4RGBCUBE_Random2-1695262898877

  • Print the map value and set display RGB color.

    4.4RGBCUBE_Random2-1695262907779

2.The brighter the ambient light is, the more LED on RGB CUBE will be on.

  • Initialize

    4.4RGBCUBE_Random2-1695262872751

  • Add a map block. The read value A1(0~1023) is mapped to 0-255.

    4.4RGBCUBE_Random2-1695262885688

  • Create a variable ananlogvalue and map its value as its assignment.

    6.1RGBCUBE_Photocell-Sensor-1695266477567

  • Determine the brightness

    • If analogvalue > 200, light up RGB LED in the first floor.

    • If analogvalue > 400, light up RGB LED in the second floor.

    • If analogvalue > 600, light up RGB LED in the third floor.

    • If analogvalue > 800, light up RGB LED in the forth floor.

    6.1RGBCUBE_Photocell-Sensor-1695266427518

Complete code:

6.1RGBCUBE_Photocell-Sensor-1695266755619


In this project, a photoresistor is integrated with the cube to change the light effects according to the ambient light. The cube automatically lights up in accordance with the ambient light by reading the sensor value. Herein, the cube features adaptability and intelligence, and you may gather experience in exploring the external environment.


2.7.Rhythm of Sound: Voice Control

In this project, a sound sensor is integrated with the cube to control the light by voice.


Sound Sensor

Description

Sound sensor is equipped with a microphone to detect the sound volume around its surroundings. After its detection, analog signals are output and converted into analog digital signal (AD Collect) within the voltage of 3.3V ~ 5V.

The sound sensor is applied to various conditions, such as interactions via sound volume, voice control robots, voice control switches, as well as alarm systems that are triggered by sounds.

cou15

Principle Diagram

2023-08-29_155614


Wiring Diagram

NOTE: S(Signal) is in yellow, V(Voltage) is in red, GND is in black. When wiring, please pay attention to the color and do not reverse!

sing


Code

4.4RGBCUBE_Random2-1695262034303

Upload the code to the development board, and open the serial monitor to choose the correct baud rate. Clap or pound your desk to make noise, and the sound sensor converts the detected analog signal into digital ones, so you will see the output value changes on the monitor.

2023-09-21_112846

You can rotate the potentiometer on the sound sensor to change the value of the output analog signal.

6a69d1c17ad8a15e840fab1090b69ec


Voice Control Cube

KS05754x4x4LED-8

When the sound sensor detects higher sound volume, the RGB cube will show richer and brighter colors.

This change in brightness and colors will be coordinated with the volume of the sound, forming a harmonious rhythm. In short, sounds will directly affect the light effects of the cube. Enjoy your wonderful show!

  • Initialize.

    Create a variable analogvalue and map its value as its assignment.

    KidsBlockProject-1695279085988

  • Create three functions to accomplish three kinds of light effects respectively at a high, medium and low sound volume.

    2023-09-21_150611

  • Function tuning1 achieves the light effect at low volume.

    • Define a variable time as the change speed of the lights. RGB LED will light up from the first floor to the second one, and then they are gradual off. It likes musical rhythm.

    64066ac0e19

    • If 15<analogvalue <40

KidsBlockProject-1695286800706

  • Function tuning2 achieves the light effect at medium volume.

    KidsBlockProject-1695286810938

  • Function tuning3 achieves the light effect at high volume.

    KidsBlockProject-1695286818138

Complete code:

KidsBlockProject-1695286829050


In this project, a sound sensor is integrated with the cube to control the light by voice. The board reads the value output by the sensor and automatically adjusts its lights according to the sound rhythm and volume. In this way, you may enjoy much fun of the integration between the light and sound, gathering experience in exploring the external environment.


2.8.Light Creation: Freaking Awesome Light Effects

Color Fader 1

1292711d972cd9

Code:

KidsBlockProject-1695439149469


Color Fader 2

085bdc78b6c996

Code:

KidsBlockProject-1695439185845


Tuning

18e92b3ca6a16bb85

Code:

KidsBlockProject-1695439797902


Frame

0739089a4d4a12aa

Code:

KidsBlockProject-1695440205405


Heartbeat

a753e47c5367e84

Code:

KidsBlockProject-1695440577474


Rainstorm

f63e6cff

Code:

KidsBlockProject-1695440969007


Random Colors

48e1a58183280b3a

Code:

KidsBlockProject-1695688634822



3.FAQ

Q: Is only USB interface for powering RGB CUBE USB?

A: Despite that, we also provide with 2.54mm pin power interface as power input.

Q: An error occurs when the board is burning code.

A:

  • Please check whether the USB port number is consistent with the connected one.

  • Please check whether you choose the correct board.

Q: Is RGB CUBE extended to other modules?

A: Yes. External modules can be connected to the kit via the 2.54mm pin interface. For details, please see main board pin description to ensure normal work.