JSS2 Smart House Security Lab
Loading...
JSS2 Smart House Security Lab

ROBOTICS SECURITY MISSION 002

Two-Zone Smart House Lab

SIMULATION MODE

MISSION BRIEFING · JSS2 ROBOTICS

Can a house give different warnings based on how close someone is?

Today, we are upgrading our smart house into a two-zone security system.

DETECTWARNPROTECT
AI CONCEPT IMAGE
150cm
002FIELD BUILD

01 · THE EXPERIENCE

Experience the three states

Move the simulated visitor. This dashboard is illustrative—not a live Arduino connection.

150 cm

SIMULATED READING

SECURITY DASHBOARDNORMAL
150cm

Monitoring · system ready

NORMALAbove 100 cm · LED off · silent
WARNING50–100 cm · LED flashes · silent
DANGERBelow 50 cm · LED on · one beep

Beyond 100 cm resets the next approach.

02 · ENGINEERING UPGRADE

What makes this version more advanced?

Engineers improve projects by adding more intelligent decisions.

JSS1

One simple threshold

  • One detection distance
  • LED on or off
  • One visitor alert
DETECTED
JSS2

Two-zone decisions

  • Two distance thresholds
  • Three operating states
  • Flashing warning + solid danger
  • Memory variable stops repeat beeps
  • Automatic reset when visitor moves away
50 cm100 cm

03 · THE KIT

Meet the components

Every part has one clear job in the security system.

UNO

Arduino Uno

The controller that makes decisions.

)))

HC-SR04 sensor

Measures distance using an echo.

LED

Shows warning and danger visually.

◖

Buzzer

Makes the short danger beep.

Breadboard

Lets us build without soldering.

╱╲

Jumper wires

Carry power and signals.

—▥—

220–330 Ω resistor

Protects the LED from too much current.

⌂

Cardboard house

The physical project enclosure.

04 · PLAN FIRST

The security blueprint

The sensor must face outward and stay unobstructed.

ENTRANCESENSOR MOUNTLEDBUZZERELECTRONICS COMPARTMENT
Sensor faces the visitor
LED is visible near the door
Buzzer stays accessible
Leave an access panel for the board

05 · BUILD

Build the physical house

Make the structure stable before adding electronics.

010203
  1. 01Measure and mark cardboard.
  2. 02Cut walls and the door opening.
  3. 03Join the walls and attach the roof.
  4. 04Secure the house to a stable base.
  5. 05Leave access for the electronics.
SAFETY FIRSTUse scissors or a craft knife carefully with adult supervision.

06 · SENSOR WIRING

Connect the ultrasonic sensor

The HC-SR04 estimates distance by timing an ultrasonic echo.

HC-SR04
SENSOR PINARDUINO UNO
VCC5V
GNDGND
TRIGD9
ECHOD10

Distance ideatime × 0.0343 ÷ 2

07 · VISUAL SIGNAL

Connect the LED

One light, three meaningful behaviours.

OFF> 100 cmFLASHING50–100 cmSOLID ON< 50 cm
D13→220–330 Ω→LED long leg
LED short leg→GND

The resistor limits current so the LED stays safe.

08 · SOUND SIGNAL

Connect the buzzer

A short sound marks the moment danger begins.

Buzzer +→D8
Buzzer −→GND
Frequency1000 HzDuration300 ms

It beeps once when the object first enters below 50 cm—not continuously.

09 · INTEGRATION CHECK

Check the complete circuit

Trace every power, signal, and shared ground connection.

ARDUINO
UNO
HC-SR04
+
SENSOR POWERTRIG D9 · ECHO D10LED D13 + RESISTORBUZZER D8SHARED GND

Connection checklist

Disconnect USB power before changing wires.

10 · PICTOBLOX LAB

Enter the PictoBlox lab

PictoBlox visual blocks are our primary programming method.

PICTOBLOX · STAGE MODE
⚑INTERFACE ILLUSTRATION
  1. 01Open PictoBlox and choose Block Coding.
  2. 02Select Arduino Uno.
  3. 03Connect the correct COM port.
  4. 04Select Stage Mode.
  5. 05Upload firmware if prompted; keep USB connected.
HONEST ENGINEERING NOTEInterface labels vary by version. Use the intended function, and move to the backup program if a required block is unavailable.

11 · BLOCK TOOLBOX

Discover the programming blocks

Find the function first; exact labels may vary with your PictoBlox version.

EVENTS
when green flag clicked
CONTROL
forever
if · then · else
wait 0.2 seconds
OPERATORS
distance > 100
distance ≥ 50
visitorAlerted = 0
VARIABLES
set visitorAlerted to 0
set visitorAlerted to 1
ARDUINO UNO EXTENSION
ultrasonic distance · TRIG 9 · ECHO 10
digital pin · HIGH / LOW
play tone on pin 8 · if available

12 · MEMORY VARIABLE

Create the visitorAlerted variable

This tiny memory prevents an annoying repeated beep.

visitor
Alerted
0
0

This approach has not triggered the danger beep.

1

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

Build the two-zone PictoBlox logic

Assemble the intended logic with the blocks available in your installed extension.

when green flag clicked
set [visitorAlerted] to [0]
set digital pin [13] to [LOW]
forever
read ultrasonic distance · TRIG 9 · ECHO 10
if distance > 100 then
LED LOW · visitorAlerted = 0
else if distance ≥ 50 then
LED HIGH → wait 0.2 → LOW → wait 0.2
else
LED HIGH
if visitorAlerted = 0
set visitorAlerted to 1 · play 1000 Hz for 0.3 s
wait 0.05 seconds

14 · DECISION MAP

Visualize the security flowchart

The loop reads, decides, signals, and repeats.

START
↓
READ DISTANCE
↓
DISTANCE > 100 CM?
YESLED OFF · reset
NOcheck 50 cm
≥ 50 CMFLASH LED · no beep
< 50 CMLED ON · beep if 0
↻
REPEAT

15 · FIELD TEST

Test the three zones

Use a ruler or tape measure with the real house. These readings are simulated here.

150100500
150 cm
TEST A · 150 cmLED OFF · buzzer silent · NORMAL
TEST B · 75 cmLED flashes · buzzer silent · WARNING
TEST C · 30 cmLED solid · one short beep · DANGER

Move back past 100 cm, then approach again: a new alert is allowed.

16 · PLAN B

Blocks missing? Engineers always have a plan B!

This is Arduino C++ backup code—not code to paste into the visual block canvas.

smart_house_security.ino
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);
}
pulseIn reads the echo pulse.The formula estimates centimetres.visitorAlerted prevents repeat beeps.Use Arduino IDE or another compatible Arduino workflow to upload it.

17 · DEBUG DECK

Troubleshoot the security system

Good engineers change one thing, test, and observe the result.

?

Sensor block unavailable

Confirm Arduino Uno, the required extension, and Stage Mode support.

♪

Buzzer does not beep

Check D8, GND, polarity, tone block, or use the backup code.

●

LED does not flash

Check D13, resistor, LED polarity, and the warning condition.

↻

System beeps repeatedly

Set visitorAlerted to 1 after the beep; reset only above 100 cm.

⟳

System does not reset

Check readings and the greater-than-100 cm condition.

≈

Readings are inconsistent

Check loose wires, sensor direction, power, and obstructions.

18 · MISSION DEBRIEF

Mission complete!

You built a smarter house.

AI CONCEPT IMAGE
NORMALblue monitoring
WARNINGamber flashing
DANGERred alert
  • Physical house built
  • Sensor, LED, and buzzer connected
  • PictoBlox logic assembled
  • Three states tested
  • Backup Arduino code ready
DETECT→WARN→ALERT→RESET

Explain how two distance thresholds make this more advanced than the JSS1 version.

01 / 19Use ← → keys to navigate