A student is writing a program to control a smart fan. The program is designed to start the motor automatically when the ambient light sensor detects that a lamp in the room has been turned on. In the context of event-driven programming, what is the most appropriate term for the specific block of code that contains the instructions to start the motor?
Senior Secondary (HKDSE) · Information and Communication Technology
Applications of Programming in Real Life :練習問題
その場で採点される選択問題 5 問と、解説つきの記述問題 5 問。すべて「Applications of Programming in Real Life 」からの出題です。
In an event-driven program for a robotic arm, the system needs to respond to various inputs. Which of the following scenarios describes a sensor-based event rather than a user-action event?
When constructing a program that uses speech recognition to control a motor, why is it often necessary to implement asynchronous event handling rather than simple sequential polling of the audio input?
When developing a program to interact with specialized physical hardware such as an accelerometer or a speech recognition module, what is the primary advantage of using extended programming modules or libraries?
A student is developing a program for an automated greenhouse. The program must monitor the ambient brightness and trigger a motor to close the blinds when the light level exceeds a specific value. Which component of event-driven programming is primarily responsible for executing the code to close the blinds when this light threshold is reached?
A student is developing an event-driven program for an automatic street lighting system. Describe the event that would trigger the system to turn the lights on and name one physical output device that the program would control.
まず自分で答えを書いてから、解説と照らし合わせましょう。
A high-tech fitness watch uses a built-in accelerometer and a vibration motor to assist users in maintaining a proper running pace. Describe the logical flow of an event-driven program for this device that triggers a tactile alert when the user's sudden acceleration exceeds a pre-defined threshold, and specify which component acts as the event source.
まず自分で答えを書いてから、解説と照らし合わせましょう。
Consider a smart doorbell system designed to take a photo when motion is detected. Explain how an event handler would be structured to manage this functionality, identifying the specific event and the corresponding action.
まず自分で答えを書いてから、解説と照らし合わせましょう。
A logistics company is developing an automated parcel sorting system that uses a robotic arm controlled by a microcontroller. The system includes a weight sensor, an accelerometer to detect if the platform is unstable, and servo motors to move parcels into different bins.
(a) Explain the difference between using a polling method and an event-driven method to monitor the accelerometer for instability. State one advantage of the event-driven approach in this real-life application.
(b) The developers use an extended programming library to control the motors. Describe two benefits of using such a library instead of writing low-level code to communicate with the hardware.
(c) The sorting logic is defined as follows:
- If the accelerometer detects a tilt where the vertical acceleration falls below a threshold, i.e., \( a_z < 9.0 \) \( m/s^2 \), the system must immediately call a function EmergencyStop().
- Otherwise, it reads the weight \( W \). If \( W \ge 5 \) kg, it triggers MoveArm(Bin_A). If \( 0.5 \le W < 5 \) kg, it triggers MoveArm(Bin_B). If \( W < 0.5 \) kg, the parcel is ignored.
Write a pseudocode segment for the event handler onWeightChange(W, az) that implements this logic.
まず自分で答えを書いてから、解説と照らし合わせましょう。
A logistics warehouse uses a fleet of automated guided vehicles (AGVs) to transport goods. Each AGV is equipped with an accelerometer and a motor controller. The AGV program must automatically stop the motor if the vehicle detects a sudden impact or tilt beyond a safe threshold to prevent damage.
(a) Explain how the accelerometer acts as an input device for this real-life application and describe the specific type of data it would capture for the program.
(b) In the context of event-driven programming, identify the 'event' that would trigger the emergency stop and explain how an event handler would be used to manage this situation.
(c) The development team decides to use an extended programming module to interface with the AGV's hardware. State two advantages of using such a module instead of writing the hardware-level communication code from scratch.
(d) Suggest another physical device that could be integrated into the system using a similar programming approach to help the AGV avoid obstacles, and name the corresponding physical output action the program should perform when an obstacle is detected.
まず自分で答えを書いてから、解説と照らし合わせましょう。
※ thinkaのコンテンツはAIにより生成されているため、内容が正確でない場合があります。補助教材としてご使用いただき、公式の教材と合わせてご確認ください。
模範解答は見ました。次はあなたの答案を採点します。
このページは良い答案の形を示せますが、あなたの答案に何が足りないかは教えられません。thinka は実際の採点基準に沿って記述答案を約 15 秒で採点します。
同じような問題をもっと解きたい?このトピックの新しい問題を、解きながら採点。
練習を始める