One simple threshold
- One detection distance
- LED on or off
- One visitor alert

ROBOTICS SECURITY MISSION 002
Two-Zone Smart House Lab
MISSION BRIEFING · JSS2 ROBOTICS
Today, we are upgrading our smart house into a two-zone security system.
01 · THE EXPERIENCE
Move the simulated visitor. This dashboard is illustrative—not a live Arduino connection.
SIMULATED READING
Monitoring · system ready
Beyond 100 cm resets the next approach.
02 · ENGINEERING UPGRADE
Engineers improve projects by adding more intelligent decisions.
03 · THE KIT
Every part has one clear job in the security system.
The controller that makes decisions.
Measures distance using an echo.
Shows warning and danger visually.
Makes the short danger beep.
Lets us build without soldering.
Carry power and signals.
Protects the LED from too much current.
The physical project enclosure.
04 · PLAN FIRST
The sensor must face outward and stay unobstructed.
05 · BUILD
Make the structure stable before adding electronics.
06 · SENSOR WIRING
The HC-SR04 estimates distance by timing an ultrasonic echo.
Distance ideatime × 0.0343 ÷ 2
07 · VISUAL SIGNAL
One light, three meaningful behaviours.
The resistor limits current so the LED stays safe.
08 · SOUND SIGNAL
A short sound marks the moment danger begins.
It beeps once when the object first enters below 50 cm—not continuously.
09 · INTEGRATION CHECK
Trace every power, signal, and shared ground connection.
Disconnect USB power before changing wires.
10 · PICTOBLOX LAB
PictoBlox visual blocks are our primary programming method.
11 · BLOCK TOOLBOX
Find the function first; exact labels may vary with your PictoBlox version.
12 · MEMORY VARIABLE
This tiny memory prevents an annoying repeated beep.
This approach has not triggered the danger beep.
The danger beep already happened in this approach cycle.
When the visitor moves beyond 100 cm, reset to 0 for the next approach.
13 · BUILD THE LOGIC
Assemble the intended logic with the blocks available in your installed extension.
14 · DECISION MAP
The loop reads, decides, signals, and repeats.
15 · FIELD TEST
Use a ruler or tape measure with the real house. These readings are simulated here.
Move back past 100 cm, then approach again: a new alert is allowed.
16 · PLAN B
This is Arduino C++ backup code—not code to paste into the visual block canvas.
const int trigPin = 9;
const int echoPin = 10;
const int ledPin = 13;
const int buzzerPin = 8;
bool visitorAlerted = false;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
digitalWrite(ledPin, LOW);
}
void loop() {
long duration;
float distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH, 30000);
if (duration == 0) {
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
visitorAlerted = false;
delay(100);
return;
}
distance = duration * 0.0343 / 2;
if (distance > 100) {
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
visitorAlerted = false;
} else if (distance >= 50) {
digitalWrite(ledPin, HIGH);
delay(200);
digitalWrite(ledPin, LOW);
delay(200);
} else {
digitalWrite(ledPin, HIGH);
if (!visitorAlerted) {
tone(buzzerPin, 1000, 300);
visitorAlerted = true;
}
}
delay(50);
}17 · DEBUG DECK
Good engineers change one thing, test, and observe the result.
Confirm Arduino Uno, the required extension, and Stage Mode support.
Check D8, GND, polarity, tone block, or use the backup code.
Check D13, resistor, LED polarity, and the warning condition.
Set visitorAlerted to 1 after the beep; reset only above 100 cm.
Check readings and the greater-than-100 cm condition.
Check loose wires, sensor direction, power, and obstructions.
18 · MISSION DEBRIEF
You built a smarter house.
Explain how two distance thresholds make this more advanced than the JSS1 version.