Introduction: Anti-thief System

Anti-theft system. And as long as there is an object passing, the attached LED lamp has a strong exposure, because it is easy to be found, the light can cause the home or the owner of the item to pay attention, and instantly know that the item in the home is stolen or touched at will.

Step 1: Materials

  1. LED x1 (any color)
  2. Arduino Leonardo x1
  3. Jumper wires 150mm x8
    1. Jumper wires x4 for Ultrasonic sensor
    2. Jumper wires x4 for LED
  4. 1.2 K ohm resistor x1
  5. Ultrasonic sensor x1
  6. Breadboard x1
  7. USB 2.0 Cable x1
  8. Cardboard 30cmx10cm x1
  9. Tape x1
  10. Cesar x1
  11. Arduino block (on the computer)
  12. Anything that you want to protect or make secure of

Step 2: Methods:

Arduino Block (code)

int ledPin12 = 12; //設定D12為LED的連接腳位

void setup() //只會執行一次

{pinMode(12, OUTPUT); //設定D12模式為輸出

Serial.begin(9600); //設定鮑率為9600


void loop() //在LOOP裡面的程式會一直重複執行


int a; //超音波變數

a= Ping(8); //超音波變數(a)=副程式Ping(第八腳位)所計算的值

Serial.println(a); //可以顯示在電腦上,使用放大鏡可以查看,在使用前必須設定鮑率

if(a<100) //如果超音波小於10公分

{ analogWrite(12, 255);} //D12輸出高電位

else //其他

{ analogWrite(12, 0);} //D12輸出低電位


//------------------------超音波 副程式------------------------------------------

long Ping(long pingPin) {

long duration, cm; // 宣告 超音波接收數值,轉換CM

pinMode(pingPin, OUTPUT);

digitalWrite(pingPin, LOW);


digitalWrite(pingPin, HIGH);


digitalWrite(pingPin, LOW);

pinMode(pingPin, INPUT);

duration = pulseIn(pingPin, HIGH);

return cm = duration / 2.9 / 2; }

//------------------ 結束 超音波 副程式--------------------------------------

Assemble the system


  1. Put the LED on the breadboard
  2. Jumper wire one connects the positive on the breadboard with the SV on the Arduino Leonardo, and another one connects the negative on the breadboard with the GND on the Arduino Leonardo.
  3. Third jumper wire connects the LED's short leg on the breadboard with the negative on the breadboard.
  4. The last jumper wire for LED is to connect the LED long leg on the breadboard with the D Pin 12 on the Arduino Leonardo.

Ultrasonic sensor

  1. Put the Ultrasonic sensor on the breadboard
  2. Jumper wire one connects the Vcc on the breadboard with the positive on the breadboard.
  3. Jumper wire two connects Trig on the breadboard with the D Pin 6 on the Arduino Leonardo.
  4. Jumper wire three connects the Echo on the breadboard with the D Pin 7 on the Arduino Leonardo.
  5. Jumper wire four connect the Gnd on the breadboard with the negative on the breadboard.

Outer Casing

  1. Use the scissors to cut the 30cmx10cm into 30cm x5cm.
  2. Use tape to stick the 30cm x5 cm with the bottom of the breadboard.
  3. Bend the cover 30cm x 5cm to hide the jumper wires and Arduino Leonardo.
  4. By just showing the LED and the Ultrasonic sensor.
  5. Leave a space or hole just enough for the USB 2.0 Cable to connect with the Arduino Leonardo.
  6. Stick the 5cm x5cm cardboard that's left previously to the left side and right side of the cover.

Step 3: Work Cited