Keyboard Alarm System

The Creation of a Microprocessor System Using Arduino

Project Report, 2019

32 Pages, Grade: 1,0



1 A bstract

2 Introduction

3 Hardware

4 Software
4.1 Arduino
4.2 C#
4.3 Used APIs

5 Results and further work

6 Code
6.1 Arduino
6.2 C#

7 Ressources

1 Abstract

A microprocessor system project using Arduino was created in order to build an alarm system for the keyboard of a computer.

The alarm system consists of blinking LEDs, sound, taking a picture of the unau- thorized person, sending that image per email, login when and what that person is doing, a distraction system and also the opportunity to stop the alarm through a password.

Keywords: Arduino, Embedded system, microcontroller, alarm system, security

2 Introduction

Almost every student knows the following situation. They study in the library or in the study room and then they have to leave the study room for a few minutes to go to get a fresh coffee, refill their water bottle or to go to the bathroom. But what to do with the laptop? Leaving it unsupervised for a few minutes? What happens if someone comes and tries to use it? Also at work what happens with the computer while leaving the working place for a few minutes? Can it be that someone tries to get some information from it by trying to hack the password? Also at work sometimes you can’t even lock the computer, what to do when you have to leave the office for a short time?

For these scenarios I’ll present in the following pages a solution. How about a little system next to the computer checking if someone puts their fingers on the keyboard. These little systems looks like a little work project, so it wouldn’t be too obvious. It does not only make an alarm, which consists of noise and blinking, it also takes a picture of the thief with the integrated camera of the computer and sends it immediately to your mail-address, so that you can react fast. Furthermore a protocol is saved with the date and time, when it happened and which processes were open at that time, so what the person could see. On top of that a distraction system is starting as soon as the unauthorized person tries to do something on the computer. This distraction system consists of opening multiple programs and pictures. Of course it is possible to stop the alarm by typing on the console the right password.

3 Hardware

This project is designed out of the Arduino UNO R3 Starter Kit. The components used from this kit are: one Arduino UNO R3, one Ultrasonic sensor, one red LED, one yellow LED, one pipo sensor, 2 330R Resistors and 9 wires The build circuit looks like this:

Abbildung in dieser Leseprobe nicht enthalten

Figure 1 author's own work

Abbildung in dieser Leseprobe nicht enthalten

Figure 2 author's own work

4 Software

The Software consists of an Arduino and a C# part. The Arduino part was made with the Arduino IDE. The C# part was made with Visual Studio.

4.1 Arduino

The Arduino part consists of the detection of the distance and reacting towards it. By using serial communication on the 9600 Baud rate, it gives a signal to the C# part to take action. Furthermore it listens if a stop signal from the C# part is coming and exits the program, if this is the case. Also in the Arduino part is the alarm consisting of LEDs and sound programmed.

4.2 C#

The C# part consists of a bit more than the Arduino part. In this part more things are happening. The picture is taken, the mail is sent, the distraction system goes on and the protocol is written.

The first thing to do in this part is the serial communication. For this are Threads used. The Threads are necessary for the part of stopping the alarm. Without them the program would wait for a user input and not doing the alarm program. The picture is taken through the webcam from the computer and saved in a specific folder on the PC. Also another class is just for the webcam. In this class the AForge library is included. This class is not only made for taking a picture, it already has some methods for doing an extension for using not only the camera of the computer. As a summary it is a class for using cameras connected to the computer.

For the sending the mail, the mail-address of the user is needed and also the account log in data. Furthermore is the Port and the SMTP-Server-address from the used mail portal needed. In this case is Yahoo used. Furthermore I used in this program my own mail-address, which the account log in data and mail-address will not be in the code below. So there will be a blank space, where originally this data was filled in.

For the distraction system are some processes, which were already on my computer, used. This can be changed individually. Also which pictures are opened, can be changed. I used some non-important landscapes pictures. As programs I opened in this case notepad++, Microsoft Word, Microsoft Excel and Microsoft Powerpoint. These programs have all different sizes as a preset, when they are opened, that’s why I chose them. For the protocol is another class and one method in the main class used. The class is for writing in a text file. The method is used to detect all the processes and to remove all the common background processes. Furthermore is the date and time detected and written with the used processes in the protocol text file.

4.3 Used APIs


- Servo.h


- System
- System.IO
- System.IO.Ports
- System.Diagnostics
- System.Net.Mail
- System.Windows.Media.Imaging
- ImageCapture
- System.Drawing
- System.Security
- System.Threading
- System.Drawing.Imaging
- System.Drawing.Image
- System.Drawing
- AForge.Video
- AForge.Video.DirectShow
- System.Collections.Generic
- System.Linq
- System.Text
- System.Threading.Tasks

5 Results and further work


- Detection of usage of the keyboard through the ultrasonic sensor
- Alarm consisting of blinking LEDs and sound made of the Piepo-Sensor
- Distraction and not ability of using the PC for one minute by opening programs and pictures
- Taking a snapshot of the person trying to use the computer
- Sending an alarm mail to an preset mail-adress with an attachment of the token snapshot
- Stopping the alarm with a password
- Protocol with date, time and used processes stored on the desktop

Further work:

- Using face recognition for not triggering the alarm if it’s the user · Showing a live stream from the camera with a text underneath, that this incident is reported

6 Code

6.1 Arduino

#include <Servo.h>

#define ECHO_PIN 11 double distance = 100; double time;

int rled = 8; //Pin Red LED

int yled = 7; //Pin Yellow LED

int buzz = 12; //PIN Passive Buzzer

int trigger = 13; //Pin Ultrasonic Sensor int echo = 11;

int frequency = 600; //Frequency int lesen = 0;

String password = "1";

void setup() { pinMode(rled, OUTPUT); pinMode(yled, OUTPUT); Serial.begin(9600); pinMode(trigger, OUTPUT); pinMode(echo, INPUT);

void loop() {

// measuring the distance delay(1000);

/* shortly no voltage, so that later with sending the trigger

* signal is clear


digitalWrite(trigger, LOW);


digitalWrite(trigger, HIGH); //sending the ultrasonic wave delay(10);

digitalWrite(trigger, LOW); //stopping sending the signal

/* with the command pulse-in is the time counted till the ultrasonic wave

* returns


time = pulseIn(echo, HIGH); distance = (time/2) * 0.03432; delay(1000);

//starting the alarm, if the distance is smaller than 30 if (distance < 30)


//writing that the alarm begins for(int i = 0; i < 10; i++)

{ Serial.write("ALARM"); Serial.println();

//starting the sound and LEDs tone(12,frequency);

for(int i = 0; i < 10; i++)

frequency = 1500; digitalWrite(rled,LOW); digitalWrite(yled, HIGH); delay(100);

frequency = 600; digitalWrite(rled,HIGH); digitalWrite(yled,LOW); delay(100);

//turning of the alarm lesen =; Serial.print(lesen); delay(1000);

if(lesen != -1)

digitalWrite(rled,LOW); digitalWrite(yled,LOW); frequency = 0;


6.2 C#

using ImageCapture;

using System;

using System.Collections; using System.Diagnostics; using System.Drawing;

using System.Drawing.Imaging;

using System.IO;

using System.IO.Ports; using System.Net.Mail; using System.Security; using System.Threading;

using System.Windows.Media.Imaging;

using Image = System.Drawing.Image;

namespace ES_Project

//main class class Program

public static SerialPort mySerialPort = new


public static String password = "password"; //to stop the alarm

public static String date; public static String time; public static String hours; public static String minutes; public static String seconds;

//for completeness public Program()

//for not sending for every alarm a ton of mails


Excerpt out of 32 pages


Keyboard Alarm System
The Creation of a Microprocessor System Using Arduino
Politehnica University of Timișoara
Catalog Number
ISBN (eBook)
ISBN (Book)
Alarm System, Keyboard Alarm System, Microprocessor, Arduino, C#, security, Embedded System
Quote paper
Michelle Bettendorf (Author), 2019, Keyboard Alarm System, Munich, GRIN Verlag,


  • No comments yet.
Read the ebook
Title: Keyboard Alarm System

Upload papers

Your term paper / thesis:

- Publication as eBook and book
- High royalties for the sales
- Completely free - with ISBN
- It only takes five minutes
- Every paper finds readers

Publish now - it's free