npsm 새물리 New Physics : Sae Mulli

pISSN 0374-4914 eISSN 2289-0041


Research Paper

New Phys.: Sae Mulli 2023; 73: 992-1000

Published online November 30, 2023

Copyright © New Physics: Sae Mulli.

LEGO Education SPIKETM Prime-based Atomic Force Microscope for Science Education

Thi Ngoc Nguyen1, Luke Oduor Otieno1, Thi Thu Nguyen1, Oyoo Michael Juma1, Yong Joong Lee1*, Jae-Sung Park2, Ho Lee3†

1School of Mechanical Engineering, Kyungpook National University, Daegu 41566, Korea
2Institute of Nanophotonic Application, Kyungpook National University, Daegu 41566, Korea
3Department of Robot and Smart Systems Engineering, Kyungpook National University, Daegu 41566, Korea

Correspondence to:*

Received: September 7, 2023; Revised: October 10, 2023; Accepted: October 22, 2023

This is an Open Access article distributed under the terms of the Creative Commons Attribution Non-Commercial License( which permits unrestricted non-commercial use, distribution, and reproduction in any medium, provided the original work is properly cited.

An atomic force microscope (AFM) is a powerful analytical tool for many fields of science and engineering. Despite its usefulness, the actual instrument is highly technical and expensive, rendering it inaccessible to a majority of practitioners in science and engineering education. Growing curiosity of students through the hands-on learning method is appealing to education managers. Adoption of LEGO® or similar educational kits into a school environment can not only fascinate the interests of students for learning but also resolve the cost problems. Our conceptual AFM system constructed with LEGO® Education SPIKETM Prime kit is very much suitable for explaining the principles behind the workings of an AFM while promoting students interests in experimental aspects of scientific instrumentation.

Keywords: Atomic Force Microscope, Nanoscience, STEM Education, Lego, Python, Physics Education

Nanotechnology has been acknowledged for its contributions to improving the quality of modern life in a variety of areas such as transportation, food safety, medication, science of environment, information technology, among others. It is of a great interest to cause young learners to inherit the development and sustenance of nanotechnology. Although many educational resources are already available, most of them are just reading materials and/or limited to demonstrating or explaining simple scientific concepts. Also, it is becoming more of a social problem where students gradually lose their interests in science and mathematics at an early learning stage. Many educators offer their opinions for solving and even reversing undesirable trend. One common factor among many potential solutions involve some ways to expose students to science and engineering from earlier phases in the educational system. In order to break through the old-fashioned teaching methods and to overcome the accessibility issues, some educators have been proposing various ways to simplify educational instruments. For instance, in the recent past, some researches have been suggesting the use of macro-scale phenomena as analogies for nano-scale interactions[1, 2]. One such effort used robotic arms and software to stimulate the AFM scanning process[3]. Other approaches used computer model of an AFM alongside marbles and magnets to represent topography and interactive forces[4, 5]. In an effort to develop affordable prototypes, some groups developed AFMs from 3D-printed parts[6] and Lego® Mindstorms® Robotics[7].

The AFM was first invented in 1986 by exploiting the atomic-scale interaction between the atoms at the sample and the tip which is brought in close proximity with the sample. The AFM has made important contributions in nanoscale characterization and manipulation due to its ability to work in air, liquid, and vacuum environments. Because its operational modes involve measuring purely atomic interactions, either attractive or repulsive forces, between tip and sample, it can be used to characterize both conductive and non-conductive samples. Furthermore, when the probe tip is functionalized, it can be used to carry out magnetic, electrical, and chemical characterizations. These reasons, together with the ease with which the working mechanism of an AFM can be demonstrated, make it a prime candidate for developing an introductory nanotechnology education kit.

The concept of creative learning offered by LEGO® can help attract students to science and other STEM areas[8, 9]. LEGO® has released a variety of customized versions specifically targeting different age groups. Furthermore, the affordable cost would foresee its popular adoption in many educational environments. Having pre-college students build a conceptual AFM tool from scratch including hardware and software modules would be a compelling opportunity for learning in a typical science and engineering experimental class. Students can work individually on components of the system or work as a group to assemble the final system. Having been inspired by LEGO®-based AFM approaches, our present work aims at a broader spectrum of audiences. The use of LEGO® Education SPIKETM Prime kit is much more suitable for learners in the range of ages 10+. The LEGO® TechnicTM Large Hub for SPIKETM Prime comes with a simple operating system that offers a more friendly coding environment employing the trendy programming languages: Python and Word Blocks[10, 11].

Our LEGO® Education SPIKETM Prime-based AFM system is similar to the previous work of other groups[12, 13]. It consists of five detachable modules: (1) motion driving stage, (2) sample stage, (3) laser tower, (4) cantilever and (5) sensor tower. The constructed AFM and its workflow are shown in Fig. 1(a) and Fig. 1(b), respectively. During the assembly process, some of the modules are better built in sets. For example, the driving stage and the sample stage need to be built at the same time in order to synchronize the movement of constituent parts and for better arrangement of the gears and other moving parts. Similarly, the laser tower should be set up together with the sensor tower as the testing of optical components require both modules. More details on the construction of specific modules will be described in the following subsections.

Figure 1. (Color online) (a) Constructed LEGO® Education SPIKETM-based AFM and (b) its workflow.


LEGO components used for this project come mostly from the LEGO® Education SPIKETM Prime kit. Also, an optical light source is necessary. We have chosen a commercial red laser pointer module due to its simple power requirement. In our case, we have used a cellular phone charger (5 V, 1.5 A) to power the laser module. According to FDA regulation, red-colored lasers with power less than 5 mW can be used

for general purposes. Otherwise, students must be warned about the safety rules of using this tool. For lower grades, teacher's supervision is strictly required during laser operation.


This module serves to provide motion translation as well as the platform for the whole AFM system. To achieve the aim of making a lightweight system, it is necessary to design a mechanically stable and rigid stage in order to reduce any instability that could appear while scanning. For this reasons, two motors are clamped to the platform in our proposed design. In contrast with our system, the design of the previously reported work[13] put the X-axis motor on one side of the mobile stage with respect to X-axis. We believe that our design helps release the asymmetrical mass distribution apparent in their approach. The image of the assembled stage with motors and gear wheels is shown in Fig. 2(a).

Figure 2. (Color online) Five detachable modules of LEGO® AFM: (a) the platform where motion driving components including two servomotors and two axles of gear wheels are installed upon, (b) the bottom view and (c) the top view of the sample stage. The structures of the (d) laser tower and (e) sensor tower.


The sample stage module receives the motion transferred from motors to move the sample in a raster pattern. On the bottom view as shown in Fig. 2(b), the gear racks are attached to the sample stage in two hierarchical layers in regard to two in-plane axles. The first layer, which represents the fast scanning axis (or X-axis), is fabricated from an array of racks connected jointly together. The slow scanning axis (or Y-axis) requires only two gear racks stacked separately onto the bottom of and at the two opposite sides of the first layer. Figure 2(c) shows the top view of the sample stage module.


The optical component modules include the laser and sensor towers placed oppositely within the systems. Because of the limited quantity of LEGO® bricks in the tool kit, the laser source is better to be consolidated with the cantilever beam on the laser tower. However, this causes a vibration of the light deflected from the cantilever when the tip runs into a hard feature on a sample. Four 1×3×3 pin connector blocks with four threads are installed around the foot of the tower as shown in Fig. 2(d). The laser pointer is horizontally fixed in between the two beams but vertically adjustable. The structure of the other tower containing the optical sensors is shown in Fig. 2(e). The laser beam has to be properly aligned so the light sensor can collect as much of the reflection from the cantilever as possible.


The cantilever as shown in Fig. 3(a) is constructed with a 2×16 stud plate and a custom tip. A fragment cut out from a compact disc is glued onto the upper side of cantilever to reflect the incident laser beam onto the light sensors. The cantilever tip was first constructed with LEGO® components as shown in Fig. 3(b). However, in order to improve the resolution of the images obtained with the system we 3D printed a sharper, conical tip as shown in Fig. 3(c). The topographic images obtained with these two tips are presented in Section III.

Figure 3. (Color online) (a) Constructed cantilever with LEGO® beam part, compact disc and 3D printed tip, (b) first design of tip is created by a LEGO® part of 1×2 Slope 30° (Double Cheese) #Pieces 5295 and (c) the conical shape tip is 3D printed.


The Technic Large Intelligent Hub from LEGO® SPIKETM Prime is a light-duty, embedded system that operates on Micro-Python. Micro-Python is a stripped-down version of Python, containing only a subset of all the standard library modules[14]. The high compatibility between the two languages allows one to re-use and transfer Python codes from a computer to a microcontroller or call on a program through a Python standard shell also known as Read-Eval-Print Loop (REPL)[15]. Although Python offers a wide variety of open-source libraries, the built-in package/library modules for LEGO Hub are still limited for the direct mode control from a PC. Instead of tediously flashing the REPL shell, Python uses a work-around method by invoking the REPL in background. On this indirect interactive mode, subtle tasks such as download, start and stop program on the hub can be executed from a PC. The hub status including data of plugged-in sensors and onboard devices is updated instantly from the background REPL to the control PC. Our project owes a huge debt of gratitude to the contribution from the open-source library of Pythonic connector for the LEGO Mindstorms/Spike Prime robot hub [16].

Figure 4 illustrates the the control flow of our system. The closed-loop control refers to the scan program downloaded on the hub. The scanning algorithm employs a data feedback from one touch sensor and short term memory data to move the stage in the most desired manner. The algorithm is exemplified in details in the next section. Outside of the closed-loop control, users need to configure the scan parameters before initializing the scan process. A manually scheduled monitoring to terminate the program when scan reaches the end of the Y-axis is crucial for the subsequent scan. To move the stage back to the home position before starting a new scan, the return movement of the motors is estimated by the data that is extracted from the latest scanning session as shown in Fig. 4.

Figure 4. (Color online) Block diagram of system control of LEGO® AFM.


The Pseudocode 1 demonstrates the procedure for raster driving for the sample stage. The X-axis motor is kept running incrementally or decrementally until the system flags the stop signal (the touch sensor is pressed or the motor returns to its initial position). The motor position is encoded from 0 ° to 359 ° for a full circular rotation. After returning to the marked point (easily found on the motor), the motor's current_position is reset back to zero. This behavior is unexpected for our data acquisition. The X and Y positions of the scan stage are represented by the cumulative degrees of motors' rotation. Moving to the next scan position requires progressively adding the scanning step to the previous scan position until the scan is terminated. This is the reason why our program repeatedly set the previous position as the starting degrees_counted for the next position. Theoretically, smaller scan step sizes should improve the scan resolution. However, the resolution is also limited by stage's ability to convert small motor rotations into lateral displacements. We found that increasing the driving power for the motor also caused an increasing level of vibration of the system. We, therefore, experimentally limited the driving power to 10% of the maximum motor power.

Stage Scanning Algorithm

Define X_motor, Y_motor, upper_sensor, lower_sensor, touch_sensor

x0 ← X_motor.get_current_position

y0 ← Y_motor.get_current_position


pw ← const ⊳ pw is the constant value of power

chosen experimentally to start motor


while True do




      Print data

      while touch_sensor is not pressed do

            X_motor.run_to_position(x0 + t, pw)

            Print data

            x0 ← X_motor.getnew_current_position()

      end while



      if touch_sensor is pressed then

            Y_motor.run_to_position(y0 - t, pw)

            Print data

      end if




      x1 ← c


      while x1 >= a do


            X_motor.run_to_position(x1 - t, pw)

            Print data

            x1 ← X_motor.getnew_current_position()

      end while


      y1 ← X_motor.get_current_position


      Y_motor.run_to_position(y1 - t, pw)


      y2 ← Y_motor.get_current_position

      x2 ← X_motor.get_current_position


      x0 ← x2

      y0 ← y2

end while


Figure 5 represents the graphical user interface (GUI) of our LEGO®-AFM Desktop Application. The GUI is created with PyQt5. The front-end design integrates two panels of: configuration and visualization. The configuration panel is kept simple by only displaying a set of radio buttons with respect to the range of scanning steps (each is linked with a scanning programs stored on the hub) and a set of push buttons such as Setpoint, Run, Stop, which is used to send the corresponding operational command to the hub. The other supplemental functions are hidden inside the menu bar and can be triggered when necessitated. For example, the uppermost function (Optical Devices Alignment) initializes a small dialog which supports testing of the light detection for the optical component setup. The canvas panel of topography visualize is the space for showing obtained topographic images. It allows pivotal rotation, zoom in and zoom out effects. A set of buttons below the image including Data on Fly, Normalized Data, and Save is used to output the image on screen and to save the output in the form of an image and numerical data for later analyses.

Figure 5. (Color online) Desktop Application of LEGO® AFM: (a) main GUI, (b) configuration menu bar to trigger a hidden drop list of add-on functions and (c) a sub-window to test performance of the optical device setup.


The acquired data contain two motors' positions and two color sensors' signals. Upon moving to a new scanned position, the hub updates the values back to the PC and stores them temporarily in a logfile. The topography plot is updated approximately after a new line scan is completed.

X-axis is scanned in trace (forward from home position) and retrace (backward to the home position). For X data, the conversion from motor rotational positions to stage linear positions is computed by the ratio between the accumulated rotational degrees and the total rotation for one scanned line.

We experimentally found a cross-coupling of ±1° between the X- and the Y-axes. Z data is the weighted average from two color sensors' values as the method suggested by previously reported work[13]. After conversion, the data are separated into three 1-D arrays, sufficient to create a 3D contour map with plot_trisurf function from matplotlib.pyplot library.


The first sample plate is simply constructed with LEGO® parts as shown in Fig. 6(a). Also, the blunt tip shown in Fig. 3(b) can work decently for this sample plate. However, since most LEGO® parts have regularly repeated protrusions for mating with other parts, the second sample plate with a smoother surface was fabricated by 3D printing as shown in Fig. 6(b). The conically sharpened tip as shown in Fig. 3(c) is paired with this 3D printed sample. In order to reduce the adverse reaction between tip and the sample, features are extruded with a gentle slope of 20°. Obtained topographic images are presented for further discussions in the next subsection.

Figure 6. (Color online) Preparation of samples from (a) LEGO® six 1 × 2 Tile #Pieces 11047 placed on sample stage made of four Technic Plates 2 × 8 [7 Holes] #Pieces 223 and (b) 3D printed sample.


Figure 7 shows the topographic image of the first sample plate. Scanning step sizes in the range of 15° to 25° were found to be most appropriate for acquiring images. The minimum step size was limited by the sharpness of the tip.

Figure 7. (Color online) (a) LEGO®-sample and (b) its corresponding topographic image acquired with our LEGO®-AFM.

Figure 8 shows topographic images of the second sample plate acquired with the scanning steps of 35°,25°,15°,10° and 5°. Step sizes of 35° and 25° are too large and fail to give a good resolution in the topographic images. Smaller step sizes of 10° and 15° resolve the topographic features better as expected. Although the smallest step size of 5° improves the scan resolution as expected, the images show some spikes near the edges of the surface features due to the abrupt changes in the optical signals. The sample size is currently limited by the length of gear racks (64 mm in total). This limitation can be overcome by building a platform using larger 3D-printed parts.

Figure 8. (Color online) Topographic images of the 3D printed sample acquired with different scanning steps: (a) 3D printed sample, (b) scanned image with step size of 35°, (c) scanned imaged with step size of 25°, (d) scanned image with step size of 15°, (e) scanned image with step size of 10° and (f) scanned image with step size of 5°.

A conceptual AFM system was successfully constructed from LEGO® Education SPIKETM Prime, and the control software was written in Python. Our proposed instrumentation is cost effective, allows easier accessibility to a nano-scientific tool in STEM education, and is sufficient for demonstrating the basic working principles of an AFM.

This research was supported by the Basic Science Research Program through the National Research Foundation of Korea (NRF) funded by the Ministry of Education (NRF-2021R1I1A3056881).

  1. M. G. Jones, E. G. Gardner, M. Falvo and A. Taylor, Nanotechnol. Rev. 4, 117 (2015).
  2. A. C. Mendes, E. T. Baran, R. L. Reis and H. S. Azevedo, WIREs Nanomed. Nanobiotechnol. 5, 582 (2013).
    Pubmed CrossRef
  3. M. G. Jones, et al., Sci. Educ. 88, 55 (2003).
  4. T. A. Engstrom, M. M. Johnson, P. C. Eklund and T. J. Russin, Phys. Teach. 53, 536 (2015).
  5. D. J. Campbell, E. R. Freidinger and M. K. Querns, Chem. Educ. 6, 321 (2001).
  6. M. Chepkoech, et al., New Phys.: Sae Mulli 69, 128 (2019).
  7. K. W. Lau, H. K. Tan, B. T. Erwin and P. Petrovic. in FIE'99 Frontiers in Education, 29th Annual Frontiers in Education Conference (San Juan, PR, USA, 1999), IEEE Cat. No.99CH37011.
  8. E. Afari and M. S. Khine, Int. J. Educ. Inf. Technol. 7, 437 (2017).
  9. E. Anastasaki and K. Vassilakis, Adv. Mob. Learn. Educ. Res. 2, 443 (2022).
  10. Nanoscale Function Group,
  11. T. H. Hsieh, et al., Int. J. Autom. Smart Technol. 4, 113 (2014).
  12. Python and MicroPython - Compare and Access,
  13. Pythonic connector for the LEGO Mindstorms/Spike Prime robot hub,

Stats or Metrics

Share this article on :

Related articles in NPSM