Skip to main content

Case 2: Rice Pounding Machine


Introduction

Press button A on the micro:bit V2 board, and the 360° building-block servo rotates at full speed (-100) to drive a cam mechanism, simulating the reciprocating pounding motion of an ancient rice pounding machine (water-powered trip hammer). Press button B, and the servo stops rotating.


Learning Objectives

  1. Learn about the rice pounding machine (water-powered trip hammer / shuǐ duì) — an ancient mechanical device that uses water power to process grain.
  2. Understand event-driven programming — using button A and button B to control the start and stop of the servo respectively.
  3. Understand the cam mechanism — the mechanical principle of converting rotational motion into reciprocating linear motion.
  4. Explore the history of ancient grain processing and humanity's ingenious use of water power.

Required Materials

ItemImageQuantity
micro:bit V21
Jacdac Expansion Board1
Jacdac 25cm Connector Cable1
Jacdac Servo Module1
360° Building-Block Servo1
USB Cable1

Sensor Principle

This case does not use an external sensor module; control is achieved entirely through the built-in button A and button B of the micro:bit V2 board.

Assembly Steps


Model Principle

360° Building-Block Servo and the Cam Mechanism

The 360° building-block servo provides continuous rotational power. The cam mounted on the servo's output shaft is an irregular disc with a protruding lobe. As the cam rotates, its protruding part periodically lifts the pounder (follower). After the cam lobe rotates past, the pounder drops under gravity, striking the grain inside the stone mortar. Thus, with each full rotation of the servo, the pounder completes one cycle of "lift → drop → pound."

PhaseMotionMechanical Principle
① Cam riseCam lobe lifts the pounderRotation → Ascent
② Pounder liftPounder raised to highest pointPotential energy accumulation
③ Cam returnCam lobe rotates awaySupport removed
④ Pounder dropPounder falls under gravity into mortarPotential → Kinetic → Impact force
⑤ Cycle repeatCam keeps rotating, next pounding cycle beginsContinuous rotation → Intermittent impact

Core Principle: The cam mechanism is one of the most classic mechanical structures for converting continuous rotational motion into intermittent reciprocating linear motion.

The Rice Pounding Machine (Water-Powered Trip Hammer / Shuǐ Duì)

The rice pounding machine, known in ancient China as "duì" (碓), was originally a human-powered foot-operated dehusking tool — a person stepped on a pedal to lift the hammer head, and when the foot was released, the hammer head dropped into the stone mortar to pound grain. In the late Western Han Dynasty (~1st century CE), the Chinese invented the water-powered trip hammer (shuǐ duì) — using flowing water to turn a waterwheel, whose axle-mounted paddles intermittently pressed down on the hammer lever, achieving automatic rice pounding. During the Three Kingdoms period (260–270 CE), Du Yu invented the linked trip hammer (lián jī duì) — a single waterwheel could simultaneously drive 4–12 hammer heads, increasing efficiency by more than tenfold.


Connection Diagram

As shown below, insert the micro:bit V2 board into the Jacdac expansion board, and use a cable to connect the servo module to the Jacdac expansion board's edge connector.

Connection Diagram


Programming Software

Microsoft MakeCode


MakeCode Programming

Step 1: Adding the Jacdac Extension

  1. Go to Microsoft MakeCode and click "New Project".

    New Project

  2. Enter a project name in the pop-up window and click "Create".

    Create Project

  3. Click "Extensions" in the code drawer.

    Extensions

  4. In the pop-up interface, type "Jacdac" and click the search icon, then select the Jacdac software library as shown.

    Search Jacdac


Step 2: Connecting the Hardware

  1. Use a USB cable to connect the micro:bit V2 board to the computer.

    Note: If this is the first time running a Jacdac program on the micro:bit V2, please pre-load a blank Jacdac program onto the board first. Otherwise, skip this step.

    Connect micro:bit

  2. Connect the sensor. MakeCode will automatically detect and simulate it in the simulator area, where the sensor status is displayed in real time.

    Sensor Simulation

  3. Click "ADD BLOCKS" to add the sensor extension module.

    Note: When connecting a new sensor, repeat the "click 'ADD BLOCKS'" workflow once.

    ADD BLOCKS


Write the Program as Shown

Program Screenshot


https://makecode.microbit.org/_R8wF0r2ktJR5

You can also download the program directly from the webpage below. Once downloaded, you can start running the program.


Result

Press button A on the micro:bit V2 board, and the 360° building-block servo rotates at full speed, driving the cam mechanism. The pounder begins reciprocating up and down, simulating the water-powered trip hammer starting operation. Press button B, and the building-block servo stops rotating and the pounder stops pounding — simulating the closing of the sluice gate and the waterwheel coming to a halt.


Think

  1. Besides pounding rice, what other applications of the cam mechanism can you find in daily life? (Hint: look at sewing machines, engine valves)
  2. If you wanted the pounder to strike with more force, how could you modify the shape of the cam?

Program Logic

Trigger ConditionActionSource
Button A pressed360° building-block servo rotates at full speed (-100), driving the cam mechanism; pounder begins reciprocating up and downmicro:bit Button A
Button B pressed360° building-block servo stops rotating; pounder stops poundingmicro:bit Button B

Knowledge Extension: From Manual Pounding to Water-Powered Automation — The Millennia-Long Evolution of Grain Processing

I. The Journey of a Grain of Rice — Why Do Humans "Pound" Rice?

Rice harvested from the field cannot be eaten directly. Each grain of rice is encased in a hard husk (chaff) that must be removed before the edible grain is obtained. In ancient times without machines, humans first used stones to smash and wooden sticks to pound. Later, they invented the mortar and pestle (chǔ jiù) — a stone mortar paired with a wooden pestle, manually pounded up and down to remove the husk.

Processing MethodApproximate EraEfficiency (per person/day)Labor Intensity
Stone smashing / hand peelingNeolithic (~10,000 years ago)~5–10 kgExtremely high
Mortar and pestle (handheld)~5,000 years ago~15–20 kgVery high
Foot-operated trip hammerWarring States (~400 BCE)~50–80 kgHigh
Water-powered trip hammer (single head)Late Western Han (~1st century CE)~150–300 kgVery low (automated)
Linked trip hammer (4–12 heads)Three Kingdoms (260 CE)~600–3,600 kgVery low (automated)
Modern rice millLate 19th century–presentSeveral tons per hourZero (fully automatic)

From mortar-and-pestle to linked trip hammer, efficiency increased by over 300 times. The water-powered trip hammer is one of the earliest great inventions in human history to achieve "production automation."


II. The Water-Powered Trip Hammer — Ancient China's "Smart Factory"

The water-powered trip hammer is hailed as one of the most ingenious water-powered machines of antiquity, integrating three core technologies:

                         ┌─────────────────────────┐
│ Trip Hammer System │
└──────────┬──────────────┘
┌───────────────────────┼───────────────────────┐
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ Power Section │ │ Transmission │ │ Work Section │
│ (Waterwheel) │ ──► │ (Axle+Board) │ ──► │ (Lever+Head) │
└───────────────┘ └───────────────┘ └───────────────┘
Water flow turns Paddles on axle Paddle pushes lever
the waterwheel intermittently tail down; head
Potential→Kinetic push the lever rises→drops under
(Nature's input) (Rotation→Recip.) gravity (impact)
Technical ElementCorresponding PrincipleImplementation in This Case
Waterwheel rotationHydraulic → Rotational kinetic energy360° building-block servo rotation
Paddle / CamRotation → Reciprocating linear motionCam mechanism
Pounder impactGravity-driven drop impactFree drop after cam rise
Water flow controls speedInput energy regulationMicrophone sound level → RPM mapping

III. The Impact of Water-Powered Trip Hammers on Ancient Society

  • Population growth support: During the Southern Dynasties, the widespread adoption of trip hammers dramatically increased grain processing efficiency, supporting rapid population growth in the Jiangnan region. Historical records indicate that at its peak, the Gushui River basin near Luoyang alone hosted dozens of trip hammers.
  • Rice price reduction: Western Jin dynasty documents record that after the spread of trip hammers, rice prices in the Luoyang area fell by about 30%, significantly reducing living costs for ordinary people.
  • Expanded applications: Trip hammers were not only used for pounding rice, but also for crushing medicinal herbs, grinding spices, pounding porcelain clay (ceramic raw material), pulping paper material, and crushing ores — truly the ancient "universal pulverizer."
  • Living heritage: At its peak, the Cangnan Wanyao Village in Zhejiang had over a hundred trip hammers for pounding porcelain clay. In mountainous regions of Fujian, Jiangxi, and Hunan, trip hammers were still in normal use as late as the 1990s.

IV. Humanity's Ingenious Use of Water Energy Through the Ages

PeriodWater Energy ApplicationRepresentative Invention
~4000 BCEWater transportAncient Egyptian Nile sailboats
1st century BCEWater liftingGreek Archimedes' screw pump
1st century CEWater-powered grain poundingChinese water-powered trip hammer
1st century CEWater-powered grindingGreek/Roman water mill
3rd century CEWater-powered bellowsChinese water-powered blast furnace bellows
3rd–4th century CEWater-powered spinningChinese water-powered spinning wheel
Late 19th centuryHydroelectric powerWorld's first hydroelectric station (Wisconsin, USA, 1882)
21st centuryPumped storage / Tidal energyThree Gorges Dam (22,500 MW), offshore tidal power stations

As of 2024, hydropower remains the world's largest source of renewable electricity, accounting for approximately 14.3% of global electricity generation and providing clean power to over 1 billion people. And it all traces back to a flash of inspiration two thousand years ago, when an ancient Chinese person facing a small stream thought: "Why not let the flowing water pound the rice for us?"


V. The Loop — From Mechanism to Program

The working rhythm of the water-powered trip hammer embodies the profound wisdom of the "loop":

Mechanical Loop (Trip Hammer)Program Loop (This Case's Code)
Power sourceWater continuously striking the waterwheelLoop block repeatedly executing code
Repetition unitOne waterwheel revolution = one poundOne loop iteration = read sound + adjust speed
Regulation mechanismMore water → faster wheel → higher pounding frequencyButton A pressed → servo full speed → higher pounding frequency
Stop conditionClose sluice gate to block water flowButton B pressed → servo stops

Reflection: Ancient craftsmen achieved "automated loops" with mechanisms; today's programmers achieve "program loops" with code. Two millennia of technological progress share the same underlying logic: discover repetition → build loops → continuously optimize. The rice pounding program you are writing continues this millennia-spanning engineering wisdom.