Digital Circuit Learning System Based on Unity3D


As a new technology, virtual reality technology development has been the concern of researchers in different fields, and its application in the field of teaching has been the focus of people. On one hand, the virtual reality technology itself has unique charm and feature, which has attracted a large number of experts and scholars to explore its application in education. On the other hand, the teaching of compulsory courses in universities is faced with the shortage of teaching resources and the low enthusiasm of students. Especially in the experiment teaching process, circuit experiment plays an important role in understanding the theoretical knowledge, at the same time, let the student to independently explore unrestrictedly by time and resources as well as the important direction of future development. From this perspective, this article summarizes the development of virtual reality technology at home and abroad in today’s teaching system, with the help of unity3D and rhino, the simple teaching system is achieved. I take “Digital Circuit Technology” as the main body, and the whole design is also based on it. Through the simulation of the virtual classroom, virtual experiment box, typical chip and other structures, the learning system makes students to choose the experimental time and place freely. At the same time, students can strengthen the ability of innovation and logical thinking, start a vivid, strong interactive, efficient teaching mode. In unity3D, I achieved many interactive functions such as interface jump, output control with the development language C#.

Share and Cite:

Liang, Y. (2018) Digital Circuit Learning System Based on Unity3D. Open Journal of Social Sciences, 6, 333-343. doi: 10.4236/jss.2018.69023.

1. Introduction

1.1. Education Innovation

With the wave of informationization sweeping into all areas of society, the education system and model have also been greatly affected, and the main position of students in learning has greatly improved. However, in actual teaching, various surveys show the limitations of multimedia in presenting information. If the level of students is uneven, the teacher cannot balance the speed at which each student browses and understands the knowledge points. Therefore, the teaching progress cannot meet the needs of some students’ demand. Especially in the subject teaching that relies on multimedia comparison, learners often learn in a passive learning environment, can only follow the teacher's progress, watch the teacher's operation, it is difficult to achieve independent thinking and exploration, not really integrated into the fun and interesting In the classroom.

At the same time, the rapid development of technology has led to the widely use of virtual reality (VR) technology in the field of education. Many experts believe that the integration of virtual reality technology into teaching is a milestone in the development of information technology [1]. It not only overcomes some of the shortcomings of multimedia technology in the teaching process, but also changes the single study atmosphere. Students understand the meaning of abstract knowledge and enjoy a free, open and enjoyable classroom through the interaction with virtual scenes.

1.2. Learning Object Selection and Overall Design

Nowadays, the application of virtual reality in teaching has spread to history, biology, chemistry and other disciplines, but the simulation software of circuit teaching has always stayed at the stage of two-dimensional simulation [2]. “Digital Electronic Technology Foundation” is an important course in the electronic-majors. This course is a compulsory course of entry-level technology. It has its own system and characteristics―not only deep theory, but also very strong practical [3]. Digital circuits involve a wide range of topics, in addition to playing a pivotal role in the learning of electrical and electronic information, and the widespread use of this technology can be seen everywhere in daily life.

Due to the importance of the course, almost all electronic-related majors in universities have opened Digital Electronics and its experimental courses. Teaching resources and laboratory resources are relatively strained. Because of a limited classroom time, teachers may not be able to balance all students, leading to difficulties for students who have no basis in logic circuits to learn. Another feature of Digital Electronics Technology, extremely practical, cannot be fully reflected due to limited laboratory resources, or because the laboratory schedule is too full, students cannot have enough time to verify theoretical knowledge; and many unnecessary troubles are caused by the aging of the equipment.

Based on the above situation and combining the advantages of virtual reality technology, this paper takes "Digital Electronic Technology Foundation" as the learning object to builds a three-dimensional virtual teaching system. This design takes the basic course in the Digital Circuit as the core, and selects the representative “combination logic circuit” and “D flip-flop” as the learning content, corresponding to the half adder, full adder, full reducer, and comprehensive experiment of four people competition answer device. The teaching system consists of three modules: theoretical learning module, experimental module, and test module. This paper mainly uses unity3D to achieve environment construction, uses C# script to achieve specific interactive functions. and uses the industrial modeling software Rhino to build a complex experiment box model. The functions of the virtual teaching system mainly include: virtual classroom environment, experiment box function simulation, connection control, power switch, chip function prompt and simple test function.

Designing a complete virtual teaching system requires the following four aspects: complete functions, fine internal structure, real experimental principles and correct simulation phenomena [4]. A lot of preliminary work is needed for this purpose, and the development process and sequence are shown in Figure 1.

2. Model Construction

This design separates the static part that does not need to interact with the part that needs to interact. The static part is the classroom environment, and the interactive part is the experimental circuit box. Because the model part of the classroom has many shape and model materials online, and the demand of accuracy is not too high, it is completed by the modeling function provided by unity3D, which can save a lot of storage space and greatly facilitate operation, and do not worry about lost problem when model importing. The experimental part of the circuit box model is unique to this design, no online material, and the structure is complex, the objects are numerous, so the professional industrial modeling software Rhino is used for modeling.

When using the unity3D to build a classroom environment, we need to pay

Figure 1. 3D virtual teaching system development process.

Figure 1. 3D virtual teaching system development process.

attention to the choice of light source and the uniformity of materials. Since the teaching system only involves indoors, the point light source and spotlight can be selected to restore the scene better [5]. When the light source is determined, in order to save resources and facilitate modification, we can use unity 3D’s baking function to fix the shadows, making the classroom more realistic [6]. The result of the construction is shown in Figure 2.

The experiment box is the center of the whole experimental operation, and it is also the focus and difficulty of this modeling. This design uses Rhino's powerful surface modeling function to design the MY-226E digital test box. The electric test box contains a wide variety of experimental components. These models have different shapes, different materials and different colors. Different methods are needed to create the rendering. At the same time, the selection of the model material is also essential, such as the LED lights are set to a transparent glass material with diffuse reflectivity, and the switch and the box part are made of impervious metal material, so that the whole can better restore the real object [7]. The box model is shown in Figure 3.

Unlike the experimental box, the experimental chip must ensure accuracy while being aesthetically pleasing. The function chip involved in this experiment is divided into fourteen pins and sixteen pins, including 74LS175 synchronous

Figure 2. Virtual classroom environment.

Figure 3. Digital circuit experiment box.

four D flip-flop, 74LS04 inverter, 74LS08 two-input NAND gate-chip, 74LS20 four-input NAND gate-chip, etc., the arrangement and position of the test chip's pins and wires are designed by scaling the data according to the real chip scale, as shown in Figure 4. It is worth noting that each port pin label name is distinguished in the modeling. In the later circuit connection, the name of each model is used to obtain the pair. The object is identified and named, so the object's name must be able to uniquely identify the object.

3. Virtual Teaching System Function Realization

The main functions of this design are shown in Figure 5. The key points and difficulties are in the functional simulation of the experimental box. The following describes the implementation of each function one by one.

3.1. Learning Module

Unity3d’s own First Person Controller component makes it easy to implement the first-person view roaming classroom [8]. Drag the First Person Controller into the Hierarchy panel, then create a capsule object in the scene, and attach a camera to the capsule body, place it on the terrain, and pass W, S, A,

Figure 4. Chip modeling.

Figure 5. Functional design.

D (or Keyboard direction key) Controls the direction of the person’s movement. By moving the mouse to look around the classroom, pressing the space bar to jump [9]. This is the first scene for users to enter the learning system. First-person roaming helps to improve the immersive experience and greatly increase students’ interest in learning.

Courses can be learned in a variety of ways, including videos, PowerPoint or other forms. Considering that most of the universities are now explained in PowerPoint because the PowerPoint have more resources, and it is convenient for uploaders to modify and add learning content, this design takes PowerPoint learning as an example. When the user clicks “Start Learning”, the selected course name appears. The course is selected by the following Ray() function, where 0 corresponds to the left mouse button, 1 corresponds to the right button, and 2 corresponds to the middle button [10]. Take the study of study1 as an example:

If(Input.GetMouseButtonDown(0)) //Monitor mouse button press

if(Input.GetMouseButtonDown(0)) //Monitor mouse button press


Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

//Create a ray

RaycastHit hit;

//Save the object information that the ray collides to in the hit

if( == "study1")

//Detect click to "study1"

{index = 0;

image.sprite = studyimage1[index];

choosedImage = studyimage1;


// Show the first picture of the course slide

ClosePlayer();} // Close the first person controller and enter learning

After all the pictures have been played, choose to return or enter the experiment:

public void Return()


image.gameObject.SetActive(false); // Close the PowerPoint

OpenPlayer();} // Open the first person controller

public void GotoNextScene()

{SceneManager.LoadScene("Scene2");} // Enter the experimental scene

3.2. Circuit Box Initialization

The initialization of the circuit box includes: 1) defining the AND, OR, and NOT-basic arithmetic symbols to prepare for the subsequent implementation of the chip; 2) chip pin settings, according to the actual situation, each chip can work normally only when correctly connected to the power supply and ground; 3) Define the basic connection rules, such as each LED light can only correspond to one output, one switch can correspond to multiple inputs, and can not be connected repeatedly. The pin setting is implemented by checking the key&value value. The wire check can be implemented by traversing the attribute value. The specific script is as follows:

public static ChipJack operator + (ChipJack data1, ChipJack data2)

{if ( == 1 || == 1)

return new ChipJack { data = 1 };

return new ChipJack { data = 0 }}

//Define the "and" operator

public virtual void CheckIsCanUse()

{isCanUse = false; bool ispositive = false;bool isnegative = false;

// initialize

foreach (var jack in CircuitBox.Instance.connectedJack)

// change the chip holes and judge them one by one

{if(jack.Key == positiveInput && jack.Value == positive)

{ispositive = true;} // The power cord is connected correctly

else if(jack.Key == negativeInput && jack.Value == negative)

{isnegative = true;}// The ground wire is connected correctly

if (ispositive && isnegative)

isCanUse = true;

// The chip can work normally

if (nowchoose != lastChooseJack)

// If the two selected pins are the same

{if (lastChooseJack.isInput == nowchoose.isInput)

// Determine whether it is all input

{OpenTip("Do not allow this connection line!"); }

3.3. Chip Function Implementation

With the definition of basic operators and chip pin settings, the implementation of the combined gate chip becomes very easy. For example, the input and output relationship of the 74LS20 can be expressed directly by an expression:

chipoutput[0].data = (!(input[0] * input[1] * input[2] * input[3])).data;

For the 74LS175 involving the D flip-flop, we need the InvokeRepeating() function to simulate the clock signal, and the clock signal can be looked as an input condition [11].

if (clockinputdata == 0 && input[2].data == 1)

{isGetUp = true;} // judge the rising edge

if (isGetUp)

{ chipoutput[0].data = input[1].data;chipoutput[1].data = (!input[1]).data;} //Upward edge assignment


{chipoutput[0].data = olddata1[i]; chipoutput[1].data = olddata2[i]; }

//Otherwise keep the original data unchanged

3.4. Secondary Function

According to the author's observation and daily experiment experience, this experiment box is designed with two additional functions: 1) In order to facilitate the experimenter to select the chip, by placing a Screen Controller script on each chip, it can be realized when the experimenter clicks on a certain chip. The corresponding pin map can appear on the screen. This can save users time to find data so improve learning efficiency. 2) In order to cultivate a good habit of the student that power-off operate, all the inputs are read and have corresponding outputs only when the “power on” is clicked. The implementation code is as follows

public class ScreenController : MonoBehaviour

{public Texture tex; // tex is the pin map corresponding to the chip

public Material mat; // mat is the display material

void OnMouseDown() // mouse down

{mat.mainTexture = tex;}}// Assign the corresponding pin map to the display

public void OpenPower() // turn on the power


InvokeRepeating("CheckAnswer", 0, 0.002f); }

// Check the input every clock cycle due to the timing circuit involved

3.5. Test Module

The test module takes five multiple-choice questions as an example, and uses the simplest loop algorithm to achieve the right and wrong judgment

{int i = 0;

(int j = 0; j < toggle.Length; j++)

{if (toggle[j].isOn)

i++;} //Note check

if (i < 3)

Text.text = "Answer right" + i + " Question! Don't be discouraged, pay attention to knowledge consolidation.";

else if(i<5)

Text.text = "Answer right" + i + "Question! Not bad, pay attention to targeted exercises after class~";


Text.text = "Answer right" + i + "Question! Very good, pay attention to review in time~";}

// different advise for different number of correct

4. Testing and Evaluation

Run the program and test some of the functions, as shown in Figures 6-8. The following test results show that the system already has the basic functions of a virtual teaching system.

Enter the main learning interface, click “Start Learning”, students can choose the course to be studied on the blackboard, after selecting the course, the perspective Fixed as a slideshow. After the study is over, click the button to enter the experiment section, as shown in Figure 6.

The experimental process takes the chip 74LS04 as an example. After the connection is completed, click “Power On” to display the correct experimental phenomenon, as shown in Figure 7. Complex comprehensive experiments with sequential circuits can also get correct results.

Click the test paper test to enter the test section. After the selection is completed, click Submit. The correct answer appears on the right side of the interface. After the learner checks, you can choose to review the course or to exit, as shown in Figure 8.

5. Conclusions

The design achieved the following achievements:

1) Developed a visual interface with strong interactivity and operability, which basically fulfilled the requirements of the teaching system. For students, the learning style becomes self-help and free. For developers, the software is easy to

Figure 6. Learning Module.

Figure 7. 74LS04 chip operation results.

Figure 8. Test Section

use and the teaching content is easy to modify. I recommended to the students around to try and get better feedback.

2) Using Rhino software to build a large number of digital circuit experimental virtual instrument models, from the internal structure to the shape in order to achieve the real restoration, the virtual instrument layered and processed by mapping and rendering, improved the virtual laboratory’s realism.

3) Studying the specific implementation technology of virtual laboratory development tools, and giving the innovation model of the construction laboratory, that is, building functional modules one by one based on the whole system framework. The operation mode completely follows the author’s imagination and completes the true meaning. Electrical experiment 3D virtual simulation. Accurate logic control of virtual instruments and objects in the scene, including scene angle control, collision detection, interface jump, switch control, connection control, and output phenomenon control, realizes reasonable display of experimental phenomena, and builds more reasonable digital circuit 3D virtual laboratory.

4) The publishing platform is diverse. In the later stage of development can be uniformly released into an application on a computer, or can be published to an Android platform or a network platform for the user or the experimenter to learn.

However, my system also has many shortcomings in the development process. For example, due to time problems, the model cannot be made more realistic, and it can’t join a more realistic interaction mode such as teacher-student interaction and student questioning. The experimental operation mode also has some areas to be improved. At present, the experimenter can only perform experimental operations with a fixed angle of view, and the 3D model is real, but the model is too large and takes up a lot of space, which is difficult to perform as powerful as a professional circuit simulation software. However, the original intention of the development of 3D virtual interactive technology is to improve the quality and efficiency of experimental teaching in higher education, and to develop the phenomenon of low interest and low enthusiasm for students. This is also the initial goal of this design. I believe that with the continuous improvement in the future, virtual teaching will become a backbone of future higher education.

Conflicts of Interest

The authors declare no conflicts of interest.


[1] Wei, F. (2015) Design and Implementation of 3D Modeling of Virtual Laboratory Based on Unity and 3d-Max. Beijing University of Posts and Telecommunications, Beijing.
[2] Sun, L.B. (2012) Research on Virtual Crowd Behavior Modeling and Simulation Technology. Tianjin University.
[3] Hu, G.T. (2011) Design and Development of Junior High School Physics Virtual Experiment Platform. Huazhong Normal University.
[4] Cui, G.N. (2014) Research on the Design and Application of Junior High School Geography Education Game Based on Unity 3D. Ningxia University.
[5] Yang, W.H. (2015) Case Design and Application Research of Junior High School History Teaching Based on Unity 3D. Ningxia University.
[6] Stuchlikova, L., Kosa, A., Benko, P., et al. (2017) Virtual Reality vs. Reality in Engineering Education. 2017 15th International Conference on Emerging E-Learning Technologies and Applications, 1-6.
[7] Zhang, Y. (2009) Design and Development of Research-Based Learning Based on Virtual Reality Technology. Central China Normal University, 13.
[8] Yang, Y.Z. (2017) Application Research of Unity 3d Educational Game in the Teaching of Seventh Grade History. Nanchang University, Jiangxi.
[9] Angelaki, S and Vatakis, A. (2014) The Unity Effect for Non-Speech Stimuli: A Top-Down or Bottom-Up Process. Procedia-Social and Behavioral Science, 126.
[10] Yan, H.S., Zeng, F. and Long, Y.H. (2017) Construction of Product Structure Cognitive Virtual Laboratory Based on Unity 3D. Laboratory Research and Exploration, 36, 117-121.
[11] Hua, Y. (2016) Research on Virtual Reality Technology in the Teaching of Computer Assembly and Maintenance. Zhiyin Inspirational, 3, 87-88.

Copyright © 2023 by authors and Scientific Research Publishing Inc.

Creative Commons License

This work and the related PDF file are licensed under a Creative Commons Attribution 4.0 International License.