UNIHIKER K10 Lesson1: Build a Light-Responsive Virtual Pet Dog

Ready to code a STEM-powered virtual pet? In this UNIHIKER K10 lesson, you’ll build a light-responsive digital dog that reacts like a real pet! Using graphical coding to program your companion to switch moods based on ambient light: it naps in dim settings and stays alert in bright light—all powered by the board’s built-in sensor (no wiring!). This CSTA/NGSS-aligned project delivers plug-and-play coding: from displaying dynamic text/images to debugging sensor thresholds. Let’s create a pet that bridges computational thinking and playful interaction!

Objectives

Display text and images on the UNIHIKER K10, and utilize the ambient light sensor to enable state switching for the pet dog.

Knowledge Goals

1. Learn how to display text on the UNIHIKER K10.

2. Learn how to display images on the UNIHIKER K10.

3. Learn to use the built-in light sensor on the UNIHIKER K10.

4. Master the use of logical operators.

Materials List

Hardware:

HARDWARE LIST
1 UNIHIKER K10
1 USB- C Cable

Software:

Mind+ Graphical Programming Software (Minimum Version Requirement: V1.8.1 RC1.0)

Basic Mind+ Software Usage

1. Double click to open the Mind+

The following screen will be called up

2. Click and switch to offline mode.

The next interface you see is the Mind+ programming interface. Let's see what this interface consists of.

Note: For a detailed description of each area of the Mind+ interface, see the Knowledge Hub section of this lesson.

3. Load UNIHIKER K10

Based on the previous steps, then click on "Extensions" find the "UNIHIKER K10" module under the "Board" and click to add it. After clicking "Back" you can find the UNIHIKER K10 in the "Command Area" and complete the loading of UNIHIKER K10.

4. Connect UNIHIKER K10

First of all, you need to use a USB cable to connect the UNIHIKER K10 to the computer.

Then, after clicking Connect Device, click COM7-UNIHIKER K10 to connect.

Note: The device name of different UNIHIKER K10 may vary, but all end with K10.

In Windows 10/11, the UNIHIKER K10 is driver-free. However, for Windows 7, manual driver installation is required: https://www.unihiker.com/wiki/K10/faq/#high-frequency-problem

Hands-on Practice

Now, let’s work together to complete today’s course tasks. We will start with the first K10 command and gradually learn how to display text and images on the K10, while using the built-in ambient light sensor to switch the pet dog’s states.

Task 1: Run the First Command – Display Text In this section, we will learn how to display text and show the preset text "Sleepy dog" on the K10 screen.

Task 2: Display the Pet Dog Image In this section, we will learn how to display images and show the pet dog’s picture on the K10 screen.

Task 3: Switch the Pet Dog Image Using Light Sensor In this section, we will learn how to use the light sensor equipped on the K10 to set conditions and achieve the function of switching the pet dog’s image.

Task 1: Run the First Command – Display Text

1. Hardware Setup

Ensure that the UNIHIKER K10 is connected to the computer using a USB cable.

2. Software Preparation

Make sure that Mind+ is opened and the UNIHIKER board has been successfully loaded. Once confirmed, you can proceed to write the project program.

3. Writing the Program

STEP 1:Find the " cached text" command and drag and drop it into the program.

Note: For details related to text commands, see the Knowledge Hub.

STEP 2:Find "show cached content" command to display the text.

Note: When using display-related instructions (such as text, draw line, draw rectangle, or images), you must use the "show cached content" instruction to render the content on the screen.

Complete Code:

4. Run the Program

STEP 1: Check and ensure that the UNIHIKER K10 is connected to Mind+

STEP 2: Click the "Upload" button at the top right of the interface.

STEP 3: Observe the display effect on the UNIHIKER K10 screen (refer to the image below).

Task 2: Display the Pet Dog Image

1. Writing the Program

STEP 1: Show text

STEP 2: Select the corresponding image.

STEP 3: Adjust the image coordinates and size.

The default coordinates for the "Cache Display Locally Loaded Image" instruction are (X=0, Y=0), with a width and height of 100. To ensure the overall visual effect on the screen is more appealing, we often need to adjust the image size and dimensions. In this project, we will reconfigure the parameters for the pet dog image as follows:

2. Run the Program

STEP 1: Connect the K10.

STEP 2: Click the "Upload" button in the top-right corner of the interface.

STEP 3: Observe the results. On the K10 screen, you should see the pet dog image appear.

3. Try It Out

Refer to the code for the first pet dog and add corresponding text for the other two pet dog images.

Task 3: Switch the Pet Dog Image Using Light Sensor

The logic of this process is that when K10 detects that the ambient light value is below a certain value and then above that value, then the program will continue to execute down the line, thus enabling the switching of the pet dog pictures. How do we detect the ambient light value and compare it to a specific value?

1. Writing the Program

In this game, we need to utilize the K10's on-board light sensor in order for the K10 to react to our hand approaching the K10 and then removing it to switch the dog picture.

Use of the ambient light sensor module:

Note: For more information about the built-in ambient light sensor in the UNIHIKER K10, see the Knowledge Center.

In order to measure the threshold before and after removing the hand from the ambient light, we need to display the ambient light value on the K10 screen and observe the change of the ambient light value before and after removing the hand from the sensor, so that we can get the critical threshold value. The test program is as follows:

The ambient light values measured before and after covering the ambient light sensor are as follows:

Judgment of the size of ambient light intensity:

Next, in order to make the pet dog pictures can be switched after the conditions are met, we need to set up different judgment instructions to drag and drop the above ambient light judgment blocks into. And display the cache content at the end

The full code is below:

2. Run the Program

Click to upload to your device, try blocking the UNIHIKER with your hand and removing it to feel the transformation of your pet dog's picture.

Knowlodge Hub

1. Mind+ interface introduction

We have already learned about the Mind+ interface in relation to UNIHIKER, and we are going to learn about the functions of each area in detail.

Introduction to Mind+ and the operation functions related to the UNIHIKER.

2. Text blocks introduction

3. UNIHIKER K10 on-board light sensor

UNIHIKER K10 built-in digital ambient light sensor, output ambient light physical quantity value rather than just the intensity of light and other degrees in the board is located in the following figure. Therefore, in this game, if you cannot change the picture of the dog after covering the UNIHIKER K10, pay attention to whether or not you are covering the position of the light sensor of the UNIHIKER K10.

Want to bring this project to your classroom? The UNIHIKER K10’s built-in sensors and seamless graphical coding software integration make it the ultimate tool for teaching coding and IoT concepts—no extra wiring or hardware needed. Start prototyping light-responsive games, environmental monitors, or even smart art installations.

[Get UNIHIKER K10 here]

License
All Rights
Reserved
licensBg
1