GAMERIFTRobotics & Coding Shop kits
HomeKitsFor schoolsAboutGAMERIFT Store ↗
Beginner Kit · Lesson 11 of 12

Guard Dog

An invisible beam. A watchful eye. A machine that barks when anything comes too close.

Unlock your lessons

Enter the access code from the card inside your Beginner Kit (or from your GAMERIFT order email). Your name appears on every page and printout as the licensee.

Don't have a kit yet? Get the Beginner Kit, the code ships inside. Lost your code? Contact us with your order number.

LICENSED TO , PERSONAL USE · © GAMERIFT

BRIEF The invisible torch

Shop doors that ding when you walk in. Taps that run when your hands arrive. Robot vacuums that stop before hitting the wall. All of them use the same trick: shine an invisible light, watch for its reflection. Your kit's IR obstacle module is that trick on one small board, an infrared torch and an infrared eye, side by side. When something comes close, its reflection lands in the eye and the module shouts. Today you build a desk guard that notices an approaching hand and raises an alarm, the exact skill your final build needs.

Time: 45–60 minutes · Difficulty: 3/5 · You need: Lessons 08 and 10 done (buzzer, sensor tuning).

KIT What you need

Concept · Seeing light you cannot see

Infrared is light too red for human eyes. Your TV remote is an IR torch, press a button while filming it with your phone camera and you will see it flash (most phone cameras can see IR, try it, genuinely). The module's clear bulb transmits IR; the dark bulb receives. Close object, strong reflection, detection.

Concept · Active LOW, the backwards shout

Here is the module's quirk: when it detects something, its OUT pin goes LOW, not HIGH. Many sensors and buttons signal this way (remember INPUT_PULLUP?). Engineers call it active low. It is not wrong, it is a dialect. Your code just needs to know which dialect its sensor speaks, and most modules have a little onboard LED that lights on detection, your cheat sheet while testing.

BUILD Wire it

Unplug the USB. Module pins into the breadboard, read the labels on YOUR board (usually OUT, GND, VCC).

FromToWhy
Module OUT pinR3 pin 7The detection wire
Module VCC pinR3 5VPower for torch and eye
Module GND pinR3 GNDGround
R3 pin 8Active buzzer + leg · − leg to GNDThe bark
R3 pin 13220Ω resistor → LED long leg · short leg to GNDThe visual alarm

Point the module's two bulbs out across your desk, not at a nearby wall, or it will "detect" the wall forever.

CODE Program it

// GAMERIFT Beginner Kit, Lesson 11: Guard Dog
// Something comes close: flash and bark until it leaves.

const int eyePin    = 7;
const int buzzerPin = 8;
const int lampPin   = 13;

void setup() {
  pinMode(eyePin, INPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(lampPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  if (digitalRead(eyePin) == LOW) {     // LOW = something is there (active low!)
    Serial.println("INTRUDER!");
    digitalWrite(lampPin, HIGH);        // flash...
    digitalWrite(buzzerPin, HIGH);      // ...and bark
    delay(100);
    digitalWrite(lampPin, LOW);
    digitalWrite(buzzerPin, LOW);
    delay(100);                          // on-off-on-off = urgent
  } else {
    digitalWrite(lampPin, LOW);         // all clear, stand down
    digitalWrite(buzzerPin, LOW);
  }
}
  1. Upload. Slide your hand toward the module. At some distance, the guard erupts.
  2. Tune the blue dial (tiny turns!) until it triggers at roughly a hand-span away. The module's own little LED shows you the trigger point even before your code reacts.
  3. Walk away and let it guard your snacks. It does not blink. It does not get bored. This is why factories love machines.

BREAK IT Now break it on purpose

  1. Test dark vs light objects. A white page triggers it from further away than a black sleeve, dark things swallow infrared instead of reflecting it. Real robot vacuums genuinely struggle with black carpets for exactly this reason.
  2. Point it at a sunny window. Sunlight is full of infrared and can blind or falsely trigger the eye. Where you place a sensor matters as much as the sensor.
  3. Film the transmitter bulb with your phone while the module is powered. See the faint glow your eyes cannot? You are looking at the invisible torch itself.

REMIX Make it yours

LOG IT Show and tell

Film the moment your hand triggers the guard for your lesson log. You now know every skill the final build needs. Stuck? Contact us with a photo.

Next · Lesson 12: The Sentinel, your graduation build

No more step-by-step. Next lesson you get a specification, like a real engineer gets, and you build the full desk guardian on your own: watching, measuring, counting and sounding the alarm. Everything you have learned, in one machine. Then you film it, send it in, and earn your certificate.

All lessons